home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************
-
- Legend 1.0.0
-
- Legend!! by bohm
- now for power pc
-
- About Legend Code:
- Legend was primarily written before 1992 as my first Macintosh program. Prior to this I had done
- programming for the Atari game machines as well as the Apple II. I have occassionally updated
- the program, most recently to accomodate the callback mechanism required for PowerPC code.
-
- While some of the ideas are somewhat primitive, many of the concepts are timeless. Look at the
- picts in Resedit and notice how i index into the master pictures. The master pictures are kept
- in memory at all times in an offscreen bitmap or pixmap for quick access.
-
- Earlier Macintoshes did not support Color Quick Draw, so you'll notice there are two sets
- of routines for all the copybits operations. This is no longer an issue in today's machines
- and system software so the b/w operations are not necessary; even b/w powerbooks have Color
- Quick Draw support.
-
- Legend code is for you to study and enjoy as I have learned from others.
-
- **************************************************************************/
-
-
- #include <Sound.h>
- #include <Palettes.h>
- #include <Power.h>
- #include <GestaltEqu.h>
- #include <LowMem.h>
-
- #define BASE_RES_ID 400
- #define NIL_POINTER 0L
- #define NIL NIL_POINTER
- #define NIL_REF_CON NIL_POINTER
- #define NIL_STRING "\p"
-
- #define MOVE_TO_FRONT -1L
- #define VISIBLE TRUE
- #define REMOVE_ALL_EVENTS 0
-
- #define INCLUDE_SECONDS TRUE
- #define ADD_CHECK_MARK TRUE
- #define REMOVE_CHECK_MARK FALSE
-
- #define DRAG_THRESHOLD 30
-
- #define MIN_SLEEP 0L
- #define NIL_MOUSE_REGION NIL
-
- #define WNE_TRAP_NUM 0x60
- #define UNIMPL_TRAP_NUM 0x9f
-
- #define NOT_A_NORMAL_MENU -1
- #define CLOCK_LEFT 12
- #define CLOCK_TOP 14
- #define CLOCK_SIZE 14
- #define ABOUT_ALERT 400
-
- #define STATUS_QUIT 0 /*status codes for masterstatus*/
- #define STATUS_WAIT 1
- #define STATUS_DEMO 2
- #define STATUS_GAME 3
- #define STATUS_NEWGAME 4
- #define STATUS_OVER 5
-
- #define NUM_OF_BUTTONS 4
-
- #define TOCATTA_SND 8192
- #define YUM_SND 8193
- #define FOOT_SND 8194
- #define ARROW_SND 8195
- #define OUCH_SND 8196
- #define MONEY_SND 8197
- #define KEY_SND 8198
- #define BAT_SND 8199
- #define UNLOCK_SND 8200
- #define POOF_SND 8201
- #define EEP_SND 8202
-
- /**maximums**/
- #define MAXFINALS 48
- #define MAXLEVELS 16
- #define MAXMONSTERS 24
- #define MAXMISSILES 4
- #define MAXHEALTH 128
- #define MAXOBJECTS 16
-
- #define MAXLWIDTH 24
- #define MAXLHEIGHT 16
-
- /**objectcodes**/
- #define APPLE 1
- #define KEY 2
- #define TREASURE 3
- #define MACHINE 4
- #define KEYHOLE 5
- #define GATE 6
- #define SUPERAPPLE 7
- #define INLETL 8
- #define INLETR 9
- #define RING 10
- /**monstercodes**/
- #define BAT 2
- #define DEAD 4
- #define GHOST 16
- #define POOLBALL 18
- #define ICECREAM 20
- #define BUGGLES 32
- #define BEHOLD 22
- #define BEHOLDH 23
- #define EGGLES 24
- #define DEADEGGLES 25
- /**itemcodes**/
- #define KEYITEMA 1
- #define RINGITEM 4
-
-
- /******************************************/
- /* */
- /* Menu Table */
- /* */
- /******************************************/
-
- /***Apple Menu*****************************/
- #define ABOUT_ITEM 1
-
- /***File Menu******************************/
- #define NEW_ITEM 1
- #define OPEN_ITEM 2
- #define SAVE_ITEM 3
- #define ABORT_ITEM 5
- #define QUIT_ITEM 6
-
- /***Options Menu***************************/
- #define SOUND_ITEM 1
- #define SCREENSIZE_ITEM 3
-
- /***Miscellaneous Menu*********************/
- #define PAUSE_ITEM 1
- #define INSTRUCT_ITEM 2
-
- /***Size Menu******************************/
- #define NATURAL_ITEM 1
- #define THE10BY10_ITEM 2
- #define THE12BY12_ITEM 3
- #define THE14BY13_ITEM 4
-
- /***Control Menu***************************/
- #define KEYBOARD_ITEM 1
- #define MOUSE_ITEM 2
-
- /***Menu ID Table**************************/
- #define APPLE_MENU_ID 256
- #define FILE_MENU_ID 257
- #define EDIT_MENU_ID 258
- #define OPTIONS_MENU_ID 259
- #define MISC_MENU_ID 260
- #define SIZE_MENU_ID 100
- #define START_MENU_ID 101
- #define CONTROL_MENU_ID 102
-
- /******************************************/
-
-
-
- /***structures***/
- struct finalbox
- {
- int x,y,size;
- };
-
- struct monsterdata
- {
- int status,dir,x,y,transit,pic;
- int alt1,alt2;
- };
- struct objectdata
- {
- int status,dir,x,y,transit,pic;
- int alt1,alt2;
- };
- struct missiledata
- {
- int status,dir,x,y,transit,pic;
- float alt1,alt2;
- };
-
-
- /***Variables***/
-
- #ifdef __POWERPC
- QDGlobals qd;
- #endif
-
- PicHandle gThePicture;
- EventRecord gTheEvent;
- MenuHandle gAppleMenu,gFileMenu,gOptionsMenu,gMiscMenu,
- gSizeMenu,gStartMenu,gControlMenu;
- Rect gDragRect,gmainrect;
- CursHandle gtargetcursor;
-
-
- Rect gbuttonrect[NUM_OF_BUTTONS];
- PicHandle gbuttonpicu[NUM_OF_BUTTONS];
- PicHandle gbuttonpicd[NUM_OF_BUTTONS];
-
- /*char gtheChar;*/
- unsigned char gkm[16]; /*keymap*/
-
- WindowPtr myWindow;
- Rect globRect,allrect,playrect,trueplayrect;
- Rect sqRect={0,0,256,256};
- int i,err;
-
- RgnHandle playregion; /*portion of window not incl side panel*/
- RgnHandle mousergn; /*check for mouse moved events here*/
-
- CGrafPort myCGrafPort;
- GrafPort myGrafPort;
- CGrafPtr myCGrafPtr;
- GrafPtr myGrafPtr;
- GDHandle theMaxDevice,oldDevice;
-
- Boolean colororbw;
- Boolean gsimplesound;
- int gbasepic; /*resource ID number of color pics*/
- int sizecheck=NATURAL_ITEM;
-
- Ptr mypiximage0,mypiximage1,mypiximage2,mypiximage3,mypiximage4;
- Ptr mybitimage0,mybitimage1,mybitimage2,mybitimage3,mybitimage4;
- PixMapHandle pix1,pix2,pix3,pix4;
- BitMap bit0,bit1,bit2,bit3,bit4,bitmask3,bitmask4;
-
- /*
- Piximage: PixMap: Purpose:
- screenbits myWindow screen image
- mypiximage0 myCGrafPtr->portBits primary offscreen grafport
- mypiximage1 pix1 background landscape
- mypiximage2 pix2 walls n stuff
- mypiximage3 pix3 player
- mypiximage4 pix4 monster A
-
- Bitimage Bitmap:
- mybitimage0 bit0 primary offscreen grafport
- mybitimage1 bit1 background landscape
- mybitimage2 bit2 walls n stuff
- mybitimage3 bit3 player
- mybigimage4 bit4 monster A
- myBitsmask3 bitmask3 mask for pix3
- myBitsmask4 bitmask4 mask for pix4
- */
-
- /**sound**/
- Boolean soundison;
- Handle tocattahandle,yumhandle,foothandle,arrowhandle,ouchhandle;
- Handle keyhandle,moneyhandle,bathandle,unlockhandle,poofhandle,eephandle;
- SndChannelPtr gsndchannela,gsndchannelb,gsndchannelc;
-
- /**Game Variables**/
- int gvara; /*multipurpose global*/
- Boolean gkeyormouse; /*0:keyboard 1:mouse*/
- int level; /*current level*/
- int hlevel; /*highest level achieved*/
- int startlevel; /*level desired to start at*/
- Boolean landscaperequest; /*0:nothing 1:draw landscape*/
- Boolean faderequest; /*fade or not during uplevel refresh*/
- int masterstatus; /*0:quit 1:wait 2:demo 3:play*/
- int mapx,mapy; /*upper left of map in abs coor*/
- int lmapx,lmapy; /*upper left of map in land coor*/
- int width,height; /*play area in abs coor*/
- int lwidth,lheight; /*play area in land coor*/
- int natlwidth,natlheight; /*natural area*/
- Boolean addmoremon; /*0:no more monsters 1:space left*/
- Boolean gbonuselg; /*0:not elgible*/
- int numfinal; /*number of final transfers*/
- int health,healtht; /*player health*/
- int pls,pld,plx,ply,plt,plp; /*player stuff*/
- int nummonsters; /*current number of monsters*/
- int numobjects; /*current number of objects*/
- int gnumitems; /*current number of items*/
- int occumaster; /*allows variations on occupied*/
- int score; /*player score*/
- int digit[5]; /*digits of score*/
- int gloop; /*monster and object loop*/
- Boolean gred; /*if set draw energy bar red*/
- int gitemlist[16]={0}; /*array of player items*/
- int gatestatus[4]; /*0:locked 1:open*/
- int gcard; /*card # for help*/
- int gcounter; /*updated every loop thru main game*/
-
-
-
- /** dungeon data**/
- int thislevel[16][24];
- Byte dungeon[MAXLEVELS][16][24]={
- {{0}},
- /*entry:level 1*/
- {{9, 2, 2, 2, 2, 2, 2,12, 2, 2, 2, 2, 2, 2, 2, 2,12, 2, 2, 2, 2, 2, 2, 8},
- {03,00,00,00,00,00,00,03,27,00,00,00,00,00,00,00,03,00,00,00,00,19,20, 3},
- {03,00,00,00,00,00,00,03,00,00,00,00,00,00,00,00,03,00,00,00,06,02,02,15},
- {03,00,00,00,00,00,00,03,00,00,00,00,00,00,00,00,03,00,00,00,00,00,00,03},
- {03,00,00,00,00,00,00,03,00,00,00,00,00,00,00,00,03,00,00,00,00,00,00,03},
- {13,04,00,06, 2, 2, 2,11,00,00,00,00,00,00,00,00,10,02,02,02,04,00,06,15},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03},
- {03,00,00,00,26,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03},
- {13,16,17,18,02,02,02, 8,00,00,00,00,00,00,00,00, 9,02,02,02,04,00,06,15},
- {03,00,00,00,00,00,00,03,00,00,00,00,00,00,00,00,03,29,00,00,00,00,00,03},
- {03,00,00,00,00,00,00,03,00,00,00,00,00,00,00,00,03,00,00,00,00,00,00,03},
- {03,00,00,00,00,24,00,03,00,00,00,00,00,00,00,00,03,00,00,00,00,00,00,03},
- {03,00,00,00,00,00,00,03,00,00,00,00,00,00,00,00,03,00,00,00,00,00,00,03},
- {10, 2, 2, 2, 2, 2, 2,14, 2, 2, 2, 2, 2, 2, 2, 2,14, 2, 2, 2, 2, 2, 2,11}},
- /*level2*/
- {{9, 2, 2, 2, 2, 2, 2, 2,12, 2, 2, 2, 2, 2, 2,12, 2, 2, 2, 2, 2, 2, 2, 8},
- {03,00,00,00,00,00,00,00,03,00,00,00,00,00,27,03,00,00,00,00,00,00,00, 3},
- {03,00,00,00,00,00,00,00,03,00,00,00,00,00,00,03,00,24,00,00,00,00,00,03},
- {03,00,00,00,00,00,00,00,03,00,00,00,00,00,00,03,00,00,00,00,00,00,00,03},
- {03,00,00,00,00,00,00,00,03,00,00,00,00,00,00,03,00,00,00,00,00,00,00,03},
- {13,02,02,04,00,06, 2,02,14,04,00,06,02,02,02,14,02,02,04,00,06,02,02,15},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03},
- {03,00,00,00,00,00,26,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03},
- {13,04,00,06,02,12,02,16,17,18, 8,00,00, 9,04,00,06,02,12,02,04,00,06,15},
- {03,00,00,00,00,03,00,00,00,00,03,00,00,03,00,00,00,00,03,00,00,00,00,03},
- {03,00,00,00,00,03,00,00,00,00,03,00,00,03,00,00,00,00,03,00,00,00,00,03},
- {03,00,00,00,00,03,00,00,00,00,03,00,00,03,00,00,00,00,03,00,00,06,02,15},
- {03,00,00,00,00,03,32,29,00,00,03,00,28,03,00,00,00,00,03,00,00,19,20,03},
- {10, 2, 2, 2, 2,14, 2, 2, 2, 2,14, 2, 2,14, 2, 2, 2, 2,14, 2, 2, 2, 2,11}},
- /*level3*/
- {{9, 2, 2, 2,12, 2, 2, 2, 2, 2, 2, 2,12, 2, 2, 2,02, 2, 2, 2, 2, 2, 2, 8},
- {03,00,00,00,03,00,00,00,00,00,00,28,03,00,00,00,00,00,00,00,00,00,27, 3},
- {03,00,00,00,03,00,00,00,00,00,00,00,03,00,00,00,00,00,00,00,00,00,00, 3},
- {03,00,00,00,03,00,00,00,00,00,00,00,03,00,00,00,00,00,00,00,00,00,00, 3},
- {03,00,00,00,03,00,00,00,05,00,00,00,03,00,00,00,05,29,00,00,05,29,00, 3},
- {03,00,00,00,03,00,00,00,03,00,00,00,03,00,00,00,03,00,00,00,03,00,00, 3},
- {03,00,00,00,03,00,00,00,03,00,00,00,03,00,00,00,03,00,00,00,03,00,00, 3},
- {03,00,00,00,03,00,00,00,03,00,00,00,03,00,00,00,03,00,00,00,03,00,00, 3},
- {03,00,00,00,03,00,00,00,03,00,00,00,03,00,00,00,03,00,00,00,03,00,00, 3},
- {03,00,00,00,03,00,00,00,03,00,00,00,03,00,00,00,03,00,00,00,03,00,00, 3},
- {03,00,00,00,03,00,00,00,03,00,00,00,03,00,00,00,03,00,00,00,07,24,00, 3},
- {03,00,00,00,07,00,00,00,03,00,00,00,07,00,00,00,03,00,00,00,00,00,00, 3},
- {03,00,00,00,00,00,00,00,03,00,00,00,00,00,00,00,03,00,00,00,00,00,00, 3},
- {03,00,00,00,00,00,00,00,03,00,00,00,00,00,00,00,13, 2,16,17,18,02,02,15},
- {03,00,00,00,00,00,00,00,03,26,00,00,00,00,00,24,03,00,00,00,00,19,20, 3},
- {10, 2, 2, 2, 2, 2, 2, 2,14, 2, 2, 2, 2, 2, 2, 2,14, 2, 2, 2, 2, 2, 2,11}},
- /*graveyard: level 4*/
- {{9, 2, 2, 2, 2, 2, 2, 2,02, 2, 2, 2, 2, 2, 2, 2,02, 2, 2, 2, 2, 2, 2, 8},
- {03,34,34,34,34,34,34,36,38,34,36,34,34,34,34,34,36,34,34,34,36,39,34, 3},
- {03,34,34,36,34,36,34,34,34,36,34,34,36,34,34,34,34,34,36,34,35,34,34, 3},
- {03,36,34,34,34,36,34,34,34,34,34,34,34,34,36,36,34,34,34,34,34,36,34, 3},
- {03,34,34,34,34,34,34,38,34,34,36,34,34,36,34,34,34,36,34,36,34,34,38, 3},
- {03,34,34,36,34,34,36,36,34,34,34,36,36,34,34,34,36,34,35,34,36,34,34, 3},
- {03,36,34,34,34,38,34,34,36,36,34,34,34,36,34,34,36,34,34,38,36,34,34, 3},
- {03,34,06, 2, 8,36,34,34,34,34,35,34,36,34,34,36,34,34,36,34,34,34,36, 3},
- {03,34,37,20,03,34,34,34,36,36,39,34,34,36,36,34,34,34,34,35,34,34,34, 3},
- {03,34,06,02,11,36,34,36,34,34,36,34,34,36,34,34,36,36,34,36,34,34,34, 3},
- {03,34,34,36,34,34,36,34,34,36,34,36,36,34,36,36,34,34,34,36,34,36,34, 3},
- {03,34,36,34,34,34,34,34,34,36,34,34,34,34,34,34,34,36,35,34,34,36,34, 3},
- {03,34,36,34,34,36,34,38,36,34,36,36,34,36,34,36,34,34,34,35,34,34,36, 3},
- {03,34,34,36,34,34,36,34,34,34,34,34,36,34,35,34,34,36,36,34,34,36,34, 3},
- {03,36,34,34,34,34,36,34,34,36,38,34,34,34,34,34,36,38,34,34,34,34,34, 3},
- {10, 2, 2, 2,02, 2, 2, 2, 2, 2, 2, 2,02, 2, 2, 2,02, 2, 2, 2, 2, 2, 2,11}},
- /*spiral: level 5*/
- {{9, 2, 2, 2,02, 2, 2, 2, 2, 2, 2, 2,02, 2, 2, 2,02, 2, 2, 2, 2, 2, 2, 8},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {03,00,00,00,00,00,24,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {13,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02, 8,00,00, 3},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03,00,00, 3},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03,00,00, 3},
- {03,00,00, 9,02,02,02,02,02,02,02,02,02,02,02,02,02, 8,00,00,07,00,00, 3},
- {03,00,00,03,00,00,00,00,00,00,00,00,00,00,00,00,29,03,00,00,40,00,00, 3},
- {03,00,00,03,00,00,00,00,00,00,00,00,00,00,00,06,02,15,00,00,05,00,00, 3},
- {03,00,00,03,00,00,06,02,02,02,02,02,02, 8,42,19,20,03,00,00,03,00,00, 3},
- {03,00,00,03,00,00,29,00,00,00,00,00,00,10,02,02,02,11,00,00,03,00,00, 3},
- {03,00,00,03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03,00,00, 3},
- {03,00,00,10,02,02,02,04,40,06,02,02,02,04,40,06,02,02,02,02,11,00,00, 3},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {03,24,00,00,00,00,00,00,00,00,00,00,28,00,00,00,00,00,00,00,00,00,00, 3},
- {10, 2, 2, 2,02, 2, 2, 2, 2, 2, 2, 2,02, 2, 2, 2,02, 2, 2, 2, 2, 2, 2,11}},
- /*pool: level 6*/
- {{9, 2, 2, 2,02, 2, 2, 2, 2, 2, 2, 2,02, 2, 2, 2,02, 2, 2, 2, 2, 2, 2, 8},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {13,02,02,02,02,02,02,02,02,02,02,04,42,06,02,02,02,02,02,02,02,02,02,15},
- {30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,31},
- {13,02,04,42,06,02,02,12,02,02,02,02,02,02,02,02,02,02,02,02,04,42,06,15},
- {03,00,00,00,00,00,00,03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {03,00,00,00,00,00,00,07,00,00,00,00,00,00,00,00,00,00,05,00,00,00,00, 3},
- {03,00,00,00,00,00,00,40,00,00,00,00,00,00,00,00,00,00,03,00,00,00,00, 3},
- {03,00,00,00,00,00,00,05,00,00,00,00,00,00,00,00,00,00,03,00,00,00,00, 3},
- {03,00,00,00,00,00,00,03,00,00,00,00,00,00,00,00,00,00,13,02,02,02,02,15},
- {03,00,00,00,00,00,00,03,00,00,00,00,00,00,00,00,00,00,07,00,00,00,29, 3},
- {03,00,00,00,00,00,00,03,00,06,02, 8,00,00,00,00,00,00,42,00,00,00,29, 3},
- {03,24,00,00,00,00,29,03,00,19,20,03,00,00,00,00,00,28,05,00,00,00,29, 3},
- {10, 2, 2, 2,02, 2, 2,14, 2, 2, 2,14,02, 2, 2, 2,02, 2,14, 2, 2, 2, 2,11}},
- /*open: level 7*/
- /*0,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23*/
- {{9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,02, 2, 2, 2, 2, 2, 2, 8},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {03,00,05,26,00,00,00,00,00,00,00,00,00,00,00,00,00,00,24, 6,02, 8,00, 3},
- {03,00,13,04,00,00,00,00,00,00,29,00,00,00,00,00,00,00,00,00,00, 7,00, 3},
- {03,00,03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,29, 3},
- {03,29,07,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,28,00,00,00, 3},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,05,27,00,00,00,00,00,00,00, 3},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,03,00,00,00,00,00,00,00,00, 3},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,03,00,00,00,00,00,00,00,00, 3},
- {03,00,00,00,00,06,02,02,04,00,00,00,00,00,07,29,00,00,00,00,00,00,00, 3},
- {03,00,00,00,00,00,00,00,00,24,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {03,00,05,00,00,00,28,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {03,00,10,02,04,00,00,00,00,00,00,00,00,00,00,00,00,00, 9,16,17,18,02,15},
- {03,00,00,00,29,00,00,00,00,00,00,00,00,00,00,00,00,00, 3,00,00,19,20, 3},
- {10, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,14, 2, 2, 2, 2,11}},
- /*pacmaze: level 8*/
- {{9, 2, 2,12, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,12, 2, 2, 2, 8},
- {03,00,00,03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03,00,19,20,03},
- {03,00,00,03,00, 9,02,02,04,00,06,12,04,00,06,02,02, 8,00,03,00,06,02,15},
- {03,00,00,03,29,03,00,00,00,00,00,03,00,00,00,00,00,03,29,03,00,00,00,03},
- {03,00,00,03,00,03,00,05,00,00,00,03,00,00,00,05,00,03,00,03,00,00,00,03},
- {03,00,00,03,00,07,00,13,02,04,00,07,00,06,02,15,00,07,00,03,00,00,00,03},
- {03,00,00,03,00,00,00,03,00,00,00,00,00,00,00,03,00,00,00,03,00,00,00,03},
- {03,00,00,10,02,04,00,07,00, 9,04,00,06, 8,00,07,00,06,02,11,00,00,00,03},
- {03,00,00,00,00,00,00,00,00,03,00,00,00,03,00,00,00,00,00,00,00,00,00,03},
- {03,00,00, 9,02,04,00,05,00,10,02,02,02,11,00,05,00,06,02, 8,00,00,00,03},
- {03,00,00,03,00,00,00,03,00,00,00,24,00,00,00,03,00,00,00,03,00,00,00,03},
- {03,00,00,03,00,05,00,03,00,06,02,12,02,04,00,03,00,05,00,03,00,00,00,03},
- {03,00,00,03,29,03,00,03,00,00,00,03,00,00,00,03,00,03,29,03,00,00,00,03},
- {03,00,00,03,00,07,00,10,02,04,00,07,00,06,02,11,00,07,00,03,00,00,00,03},
- {03,00,00,03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03,00,00,00,03},
- {10, 2, 2,14, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,14, 2, 2, 2,11}},
- /*lines: level 9*/
- /*0,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23*/
- {{9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 8},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {13, 2, 2, 2, 4,42, 6, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4,42, 6, 2,15},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,40,00,00,00,00,00,00,28, 3},
- {13, 2, 2, 2, 2, 2, 2, 4,00, 6, 2, 2, 2, 2, 2, 4,00, 6, 2, 2, 2, 2, 2,15},
- {03,24,00,00,00,42,00,00,00,00,00,00,00,40,00,00,00,00,00,00,00,00,27, 3},
- {13, 2, 2, 2, 2, 4,00, 6, 2, 2, 2, 2, 2, 2, 4,40, 6, 2, 2, 2, 2, 2, 2,15},
- {03,29,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,26, 3},
- {13, 2, 2, 4,00, 6, 2, 2, 2, 2, 2, 2, 4,00, 6, 2, 2, 2, 2, 4,00, 6, 2,15},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {13,16,17,18, 2, 2, 2, 2, 2, 2, 4,00, 6, 2, 2, 4,40, 6, 2, 2, 2, 2, 2,15},
- {03,00,00,00,00,00,00,00,00,00,00,40,00,00,00,00,00,00,00,00,00,00,24, 3},
- {13, 2, 2, 2, 4,00, 6, 2, 2, 2, 2, 2, 4,00, 6, 2, 2, 4,00, 6, 2, 2, 2,15},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,28,00,00,00,00,00,00,19,20, 3},
- {10, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,11}},
- /*zigzag*/
- /*0,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23*/
- {{9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,02, 2, 2, 2, 2, 2, 2, 8},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {13, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,02, 2, 2, 2,04,00,00, 3},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,28, 3},
- {03,00,00,06, 2, 2, 2, 2, 2, 2, 2, 2, 4,40, 6, 2,02, 2, 2, 4,40, 6, 2,15},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {03,24,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {13, 2, 2, 2, 2, 2, 2, 2, 2, 4,40, 6, 2, 2, 2, 2,02, 2, 2, 2,04,00,00, 3},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,29, 3},
- {03,00,00,06, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,02, 2, 2, 2, 2, 2, 2,14},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 9},
- {10, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,11}},
- /*hall*/
- {{9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 8},
- {03,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,10},
- {03,43,47,44,45,45,46,44,46,44,44,45,44,46,44,46,44,45,44,44,45,44,43,43},
- {03,43,44,44,05,44,46,44,45,05,45,46,44,46,05,45,46,44,45,05,46,45,43, 9},
- {03,43,46,44,03,44,46,28,44,03,44,44,45,44,03,44,45,46,44,03,44,44,43,03},
- {03,43,44,45,07,46,44,45,46,07,46,45,44,44,07,44,44,44,46,07,46,28,43,03},
- {03,43,44,45,44,46,44,45,46,45,46,44,46,44,45,44,45,44,46,44,46,45,43,03},
- {03,43,46,44,45,45,46,44,44,44,44,46,44,46,44,46,44,45,44,44,45,44,43,03},
- {03,43,44,45,44,46,44,44,45,46,46,46,44,45,44,45,44,46,44,46,46,45,43,03},
- {03,43,46,44,45,45,46,45,46,44,44,45,44,46,44,46,44,45,46,44,45,44,43,03},
- {03,43,44,45,05,44,46,44,45,05,45,46,45,46,05,45,44,45,44,05,44,46,43,03},
- {03,43,44,45,03,46,44,45,46,03,44,46,46,44,03,44,46,44,46,03,46,44,43,03},
- {11,43,46,44,07,45,46,44,46,07,44,45,44,46,07,46,44,45,44,07,45,44,43,03},
- {43,43,44,45,44,46,44,45,46,45,46,44,46,44,45,44,45,44,46,44,46,45,43,03},
- { 8,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,03},
- {10, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,11}},
- /*batland*/
- /*0,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23*/
- {{9, 2, 2, 2,12, 2, 2, 2,12, 2, 2, 2,12, 2, 2, 2,12, 2, 2, 2, 2, 2, 2, 8},
- {11,00,00,00,07,00,00,00,07,00,00,00,07,00,00,00,03,00,00,00,00,00,00, 3},
- {00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03,00,06,02, 8,00,00, 3},
- { 8,00,00,00,05,00,00,00,05,00,00,00,05,00,00,00,03,00,19,20,03,00,00, 3},
- {13,04,00,06,01,02,02,02,01,04,40,06,01,04,00,06,01,02,02,02,15,00,00, 3},
- {03,00,00,00,03,00,00,00,07,00,00,00,07,00,00,00,07,00,00,00,03,00,00, 3},
- {03,00,00,00,03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03,00,00, 3},
- {03,26,00,00,03,00,00,00,05,00,00,00,05,00,00,28,05,00,00,00,03,00,00, 3},
- {13,04,40,06,01,04,00,06,01,04,00,06,01,04,40,06,01,04,00,06,15,00,00, 3},
- {03,00,00,00,07,00,00,00,07,00,00,28,03,00,00,00,07,00,00,00,03,00,00, 3},
- {03,00,00,00,00,00,00,00,40,00,00,00,03,00,00,00,00,00,00,00,03,00,00, 3},
- {03,00,00,24,05,00,00,00,05,00,00,00,03,27,00,00,05,00,00,00,03,00,00, 3},
- {13,02,02,02,14,16,17,18,14,02,02,02,14,02,02,02,14,02,02,02,11,00,00, 3},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, 3},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,32, 3},
- {10, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,11}},
- /*ministone: level 13*/
- {{9, 2, 2, 2, 2, 2, 2, 2,02, 2, 2, 2, 2, 2, 2, 2,02, 2, 2, 2, 2, 2, 2, 8},
- {03,00,00,00,00,00,00,00,00,00,00,40,00,00,00,00,00,00,00,00,00,00,00, 3},
- {03,00, 9, 2, 2, 2, 2, 2,04,00,06, 2, 2,04,00,06, 2, 2, 2, 2, 2, 8,00, 3},
- {03,00,03,36,34,34,34,34,34,34,34,36,34,36,34,34,36,34,34,34,36,03,00, 3},
- {03,00,03,34,34,34,34,36,34,34,36,34,34,36,34,34,34,34,36,34,34,03,00, 3},
- {03,00,03,34,34,35,34,34,36,34,34,36,34,34,36,34,34,35,34,34,34,03,00, 3},
- {03,00,03,36,34,34,36,34,34,36,34,34,35,34,34,36,36,34,36,34,34,03,00, 3},
- {03,00,03,34,36,34,34,36,34,34,36,34,36,34,34,36,34,34,34,36,34,03,00, 3},
- {03,00,03,34,34,34,34,36,34,36,34,34,36,38,36,34,36,34,34,34,34,03,00, 3},
- {03,00,03,34,36,34,36,34,38,36,34,34,34,34,36,34,34,34,36,34,36,03,00, 3},
- {03,00,03,34,34,34,36,34,36,34,36,34,34,35,34,34,34,34,36,34,36,03,00, 3},
- {03,00,03,34,34,36,34,34,34,34,34,36,36,34,36,34,36,34,34,36,39,03,00, 3},
- {03,00,03,36,34,34,36,34,34,36,34,34,34,38,34,34,36,34,36,34,34,03,00, 3},
- {11,00,03,34,35,34,34,36,36,34,34,34,34,36,34,34,34,34,34,34,34,03,00,10},
- {00,00,03,34,34,34,34,34,34,35,34,36,34,34,35,34,34,34,34,36,34,03,00,00},
- {02, 2,14, 2,02, 2, 2, 2, 2,02, 2,02,02, 2,02, 2,02, 2, 2, 2, 2,14, 2,02}},
- /*more rooms: level 14*/
- {{9, 2, 2, 2, 2, 2, 2, 2,12, 2, 2, 2, 2, 2, 2,12, 2, 2, 2, 2, 2, 2, 2, 8},
- {03,00,00,00,00,00,00,00,03,00,00,00,00,00,00,03,00,00,00,00,00,19,20,03},
- {03,00,00,00,00,00,00,00,03,00,00,00,00,00,00,03,00,00,00,00,00,06,02,15},
- {03,00,00,00,00,00,00,00,03,00,00,00,00,00,00,03,00,00,00,00,00,00,00,03},
- {03,00,00,00,00,00,00,00,03,00,00,00,00,00,00,03,00,00,00,00,00,00,00,03},
- {13,02,02,04,00,06, 2,02,14,02,16,17,18,02,02,14,02,02,16,17,18,02,02,15},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,26,00,00,03},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03},
- {03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03},
- {03,00,00,00,00,00,26,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,03},
- {13,02,02,02,02,02,16,17,18,12,02,02,04,00,06,02,12,02,02,04,00,06,02,15},
- {03,00,00,00,00,00,00,00,00,03,00,00,00,00,00,00,03,00,00,00,00,00,00,03},
- {03,00,00,00,00,00,00,00,00,03,00,00,00,00,00,00,03,00,00,00,00,00,00,03},
- {03,00,00,00,00,00,00,00,00,03,00,00,00,00,00,00,03,00,00,00,00,00,00,03},
- {03,00,00,00,00,00,00,00,00,03,00,00,00,00,00,00,03,00,00,00,00,00,00,03},
- {10, 2, 2, 2, 2, 2, 2, 2, 2,14, 2, 2, 2, 2, 2, 2,14, 2, 2, 2, 2, 2, 2,11}},
- };
- Boolean occuval[64]={
- 0,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,
- 1,1,1,0,0,1,1,0,
- 0,0,0,0,1,1,1,1,
- 0,0,0,1,1,0,0,0,
- 1,0};
-
- char data[MAXLEVELS][MAXOBJECTS][8]={
- { {0,0,0,0,0} }, /*level 0*/
- { {APPLE,0,5,13,1,0,0,0}, /*level 1*/
- {KEY,0,8,1,1,0,0,1},
- {KEYHOLE,0,4,9,1,0,0,1},
- {GATE,0,1,10,1},
- {TREASURE,0,17,11,1},
- {BUGGLES,0,22,14,2,0,0,0},
- {BUGGLES,0,12,12,2,0,0,0}},
- { {APPLE,0,17,2,1,0,0,0}, /*level 2*/
- {SUPERAPPLE,0,6,14,1,0,0,0},
- {KEY,0,14,1,1,0,0,2},
- {KEYHOLE,0,6,9,1,0,0,2},
- {GATE,0,7,10,1},
- {MACHINE,0,12,14,1,0,95}, /*last # is speed*/
- {TREASURE,0,7,14,1,0,10},
- {BUGGLES,0,21,12,2,0,0,0},
- {BUGGLES,0,8,12,2,0,0,0}},
- { {APPLE,0,15,14,1,0,0,0}, /*level 3*/
- {APPLE,0,21,10,1,0,0,0},
- {MACHINE,0,11,1,1,0,75,0},
- {EGGLES,0,1,11,2,0,0,0},
- {EGGLES,4,2,12,2,0,0,0},
- {EGGLES,2,1,13,2,0,0,0},
- {EGGLES,2,15,10,2,0,0,0},
- {BUGGLES,0,19,6,2,0,0,0},
- {BUGGLES,0,22,6,2,0,0,0},
- {KEY,0,22,1,1,0,0,2},
- {KEYHOLE,0,9,14,1,0,0,2},
- {GATE,0,18,13,1},
- {TREASURE,0,17,04,1},
- {TREASURE,0,21,04,1}},
- { {BAT,0,11,10,2,0,-10,-10}, /*graveyard:level 4*/
- {BAT,0,11,10,2,0,32,10},
- /*{GHOST,0,16,10,2,0,0,0},*/
- {TREASURE,0,21,1,1,34,10},
- {TREASURE,0,10,8,1,34,10},
- {BAT,0,16,12,2,0,14,-10}},
- { {APPLE,0,6,2,1,0,0,0}, /*spiral:level 5*/
- {APPLE,0,1,14,1,0,0,0},
- {BUGGLES,0,18,2,2,0,0,0},
- {BUGGLES,0,22,5,2,0,0,0},
- {BAT,0,11,10,2,0,26,10},
- {TREASURE,0,6,10,1},
- {TREASURE,0,16,7,1,0,10},
- {MACHINE,0,12,14,1,0,50,0}},
- { {APPLE,0,1,14,1,0,0,0}, /*pool:level 6*/
- {BUGGLES,0,18,2,2,0,0,0},
- {BUGGLES,0,3,3,2,0,0,0},
- {POOLBALL,1,22,5,2,0,0,0},
- {BAT,0,11,10,2,0,26,10},
- {EGGLES,2,21,13,2,0,0,0},
- {TREASURE,0,22,12,1,0,10},
- {TREASURE,0,22,13,1,0,15},
- {TREASURE,0,22,14,1},
- {TREASURE,0,6,14,1},
- {INLETL,0,0,5,1},
- {INLETR,0,23,5,1},
- {MACHINE,0,17,14,1,0,45,0}},
- { {APPLE,0,18,2,1,0,0,0}, /*open:level 7*/
- {APPLE,0, 9,11,1,0,0,0},
- {EGGLES,2,12,10,2,0,0,0},
- {EGGLES,2,13,11,2,0,0,0},
- {EGGLES,2,5,7,2,0,0,0},
- {EGGLES,2,1,14,2,0,0,0},
- {TREASURE,0,1,5,1,0,5},
- {TREASURE,0,4,14,1,0,18},
- {TREASURE,0,22,4,1,0,10},
- {TREASURE,0,10,3,1},
- {TREASURE,0,15,10,1},
- {KEY,0,15,7,1,0,0,2},
- {KEYHOLE,0,3,2,1,0,0,2},
- {GATE,0,19,13,1},
- {MACHINE,0,6,12,1,0,50,0},
- {MACHINE,0,19,5,1,0,40,0}},
- { {APPLE,0,11,10,1,0,0,0}, /*pacmaze:level 8*/
- {GHOST,0,20,8,2,0,0,0},
- {GHOST,0,10,0,2,10,0,0},
- {TREASURE,0,4,3,1,0,10},
- {TREASURE,0,4,12,1,0,10},
- {TREASURE,0,18,3,1,0,15},
- {TREASURE,0,18,12,1,0,10},
- {BAT,0,12,12,2,0,-20,-10}},
- { {MACHINE,0,22,4,1,0,40,0}, /*lines:level 9*/
- {MACHINE,0,14,14,1,0,45,0},
- {BUGGLES,0,3,9,2,0,0,0},
- {KEY,0,22,6,1,0,0,1},
- {KEYHOLE,0,22,8,1,0,0,1},
- {TREASURE,0,1,8,1,0,10},
- {APPLE,0,1,6,1,0,0},
- {APPLE,0,22,12,1,0,0},
- {GATE,0,1,11,1}},
- { {MACHINE,0,22,5,1,0,40,0}, /*zigzag:level 10*/
- {BAT,0,24,11,2,0,-2,10},
- {BUGGLES,1,20,2,2,0,0,0},
- {BUGGLES,0,7,14,2,0,0,0},
- {BEHOLD,0,8,12,2,0,0,0},
- {TREASURE,0,22,11,1,0,10},
- {APPLE,0,1,8,1,0,0}},
- { {MACHINE,0,21,5,1,0,40,0}, /*great hall:level 11*/
- {MACHINE,0,7,4,1,0,40,0},
- {BUGGLES,3,3,3,2,0,0,0},
- {BUGGLES,3,10,10,2,0,0,0},
- {RING,0,2,2,1,0,0,1},
- {BEHOLD,0,8,12,2,0,0,0}},
- { {BAT,0,3,14,2,0,-3,2}, /*batland:level 12*/
- {KEY,0,13,11,1,0,0,1},
- {KEYHOLE,0,1,7,1,0,0,1},
- {GATE,0,5,12,1},
- {APPLE,0,3,11,1,0,0},
- {SUPERAPPLE,0,22,14,1,0,0,0},
- {MACHINE,0,15,7,1,0,35,0},
- {MACHINE,0,11,9,1,0,30,0}},
- { {BAT,0,15,3,2,0,-10,-10}, /*ministone:level 13*/
- {BAT,0,11,10,2,0,32,10},
- {GHOST,0,4,10,2,0,0,0},
- {TREASURE,0,20,11,1,34,19},
- {BAT,0,20,12,2,0,14,-10}},
- { {BAT,0,15,3,2,0,-10,-10}, /*more rooms:level 14*/
- {BAT,0,20,12,2,0,14,-10}}
- }; /*status,dir,x,y,0 or 1 or 2,picture,alt1,alt2*/
-
- Byte upx[MAXLEVELS]={0,21,21,21,2,15,9,21,
- 21,21,23,23,18,23};
- Byte upy[MAXLEVELS]={0,1,14,14,8,9,14,14,
- 1,14,13,2,3,14};
- Byte startx[MAXLEVELS]={1,1,1,1,1,1,1,1,
- 1,1,1,0,0,0,1};
- Byte starty[MAXLEVELS]={1,1,1,1,1,1,1,1,
- 1,1,1,13,2,14,8};
-
- int dir12x[9]={12,-12,0,0,12,-12,-12,12,0};
- int dir12y[9]={0,0,-12,12,-12,-12,12,12,0};
- int dir2x[9]={2,-2,0,0,2,-2,-2,2,0};
- int dir2y[9]={0,0,-2,2,-2,-2,2,2,0};
- int dir1x[9]={1,-1,0,0,1,-1,-1,1,0};
- int dir1y[9]={0,0,-1,1,-1,-1,1,1,0};
- int rebound[9]={1,0,3,2,6,7,4,5,9};
- int diricex[8]={2,1,0,-1,-2,-1,0,1};
- int diricey[8]={0,1,2,1,0,-1,-2,-1};
- int undu[4]={1,0,-1,0};
- int bounce[16]={-2,-4,-6,-7,-6,-4,-2,0,0};
-
- int plwalkpic[8][10]={
- {00, 1, 2, 3, 4, 5, 6, 7, 8 ,9},
- {16,17,18,19,20,21,22,23,24,25},
- {26,27,28,27,26,29,30,31,30,29},
- {10,11,12,11,10,13,14,15,14,13},
- {00, 1, 2, 3, 4, 5, 6, 7, 8 ,9},
- {16,17,18,19,20,21,22,23,24,25},
- {16,17,18,19,20,21,22,23,24,25},
- {00, 1, 2, 3, 4, 5, 6, 7, 8 ,9}
- };
-
- int batpic[16]={32,33,34,35,36,37,38,39,48,49,50,51,52,53,54,55};
- int deadbatpic[8]={32,192,193,193,208,208,209,47};
- int scorerollpic[24]={16,16,16,16,16,16,17,18,19,20,
- 21,22,23,24,25,26,27,28,29,30,31,15,15,15};
- int ghostpic[8]={40,41,42,43,44,43,42,41};
- int poolballpic[2][16]={
- {32,33,34,35,36,37,38,39,32,32,32,32,32,32,32,32},
- {39,38,37,36,35,34,33,32,32,32,32,32,32,32,32,32}};
- int bugglewalkpic[8][6]={
- {0,1,2,3,2,1},
- {4,5,6,7,6,5},
- {0,1,2,3,2,1},
- {0,1,2,3,2,1},
- {0,1,2,3,2,1},
- {4,5,6,7,6,5},
- {4,5,6,7,6,5},
- {0,1,2,3,2,1}
- };
- int egglewalkpic[8][4]={
- {205,205,204,204},
- {221,221,220,220},
- {205,205,204,204},
- {205,205,204,204},
- {205,205,204,204},
- {221,221,220,220},
- {221,221,220,220},
- {205,205,204,204}};
- int beholdpic[8]={51,52,52,53,53,52,52,51};
- int missilepic[8]={40,41,42,43,56,57,58,59};
- int arrowexplodepic[5]={44,45,60,61,62};
- int gitempic[5]={226,227,227,227,227+16};
-
- struct finalbox finals[MAXFINALS];
- struct monsterdata monster[MAXMONSTERS];
- struct objectdata object[MAXOBJECTS];
- struct missiledata missile[MAXMISSILES];
-
-
- /***Prototypes***/
- Boolean IsColor();
- Boolean IsIdle();
- Boolean ispressed(unsigned short k);
- Boolean ispressed2(unsigned short k);
- Rect multrect(register int x,register int y);
- Rect minimultrect(int x,int y);
- Rect coorrect(register int x,register int y,register int size);
- Rect coorrectl(int x,int y,int size);
- BitMap makebitmap();
- void cango(int *x,int *y,int xmod,int ymod,int direction,int size);
- void cango2(int *x,int *y,int xmod,int ymod,int direction,int size);
- Boolean occupied(int x,int y);
- void doobject(struct objectdata *);
- void doobject2(struct objectdata *);
- void domonster(struct monsterdata *);
- void domissile(struct missiledata *);
- short keydir();
- Boolean within(int x,int y,int x2,int y2,int size, int size2);
- int getdir(int x,int y);
- int getdir2(int x,int y);
-
- pascal Boolean helpfilter(DialogPtr,EventRecord *,short *);
- pascal void pictproc(WindowPtr theDlg,short theItem );
-
- pascal void okitemproc(WindowPtr theDlg,short theItem );
- pascal Boolean diafilter(DialogPtr,EventRecord *,short *);
-
-
-
-
- /*** Main ***/
- main()
- {
- FrozenInit();
- MiscInit();
- MainLoop();
- cleanup();
- }
- /**FrozenInit**/
- /*this is all the start up stuff that is done only once*/
- FrozenInit()
- {
- ToolBoxInit();
- WindowInit();
- SetUpDragRect();
- MenuBarInit();
- }
-
-
- /*** MainLoop ***/
- /*this is where we hang out when nobody is playing*/
- MainLoop()
- {
- masterstatus=STATUS_WAIT;
- landscape(0);
- offtoon();
-
- while(masterstatus)
- {
- HandleEvent();
- maintaincursor(gTheEvent.where);
- switch(masterstatus)
- {
- case STATUS_WAIT:
- level=0;
- break;
- case STATUS_GAME:
- Game();
- break;
- case STATUS_NEWGAME:
- masterstatus=STATUS_GAME;
- break;
- case STATUS_OVER:
- Over();
- break;
- default:
- break;
- }
- }
- }
-
-
- /****Game****/
- Game()
- {
- long oldticks;
- int timetest;
-
- oldticks=gcounter=0;
- sounder(gsndchannelc,tocattahandle);
- score=0;
- gbonuselg=FALSE;
- health=healtht=80;
- gnumitems=0;
- drawsidepanel();
- displayscore();
- drawhealth();
- displayitems();
- level=startlevel;
- setlevel(level);
- occumaster=0;
- EnableItem(gFileMenu,ABORT_ITEM);
- EnableItem(gMiscMenu,PAUSE_ITEM);
-
- while (masterstatus==STATUS_GAME)
- {
- HandleEvent();
- if(TickCount()<oldticks+2) timetest++;
- else timetest=0;
- while(TickCount()<oldticks+2) /*should be 2*/
- if (timetest>80)
- {
- timetest=0;
- addmoremon=TRUE;
- }
- oldticks=TickCount();
- testscroll();
-
- if (landscaperequest) landscape(level);
-
- objects();
- monsters();
- missiles();
- player();
- objects2();
- displayhealth();
-
- if (landscaperequest)
- {
- offtoon();
- landscaperequest=FALSE;
- }
- finaldraw();
- if (plx==upx[level]*32 && ply==upy[level]*32)
- uplevel();
- gcounter++;
- if (!(gcounter&63)) healtht--;
- gred=(gcounter&8); /*change color every 16 counts*/
-
- }
- DisableItem(gFileMenu,ABORT_ITEM);
- DisableItem(gMiscMenu,PAUSE_ITEM);
- }
- /**uplevel**/
- uplevel()
- {
- Str31 mystring;
-
- level++;
- setlevel(level);
- if(((hlevel+1)==level) && level<8)
- {
- hlevel++;
- NumToString(hlevel,mystring);
- if((level-1)==CountMItems(gStartMenu))
- AppendMenu(gStartMenu,mystring);
- }
- }
- /****Over****/
- Over()
- {
- long oldticks;
- int timetest;
- Rect fromrect,torect;
-
- oldticks=0;
- gbonuselg=FALSE;
- pls=5; /*set player to cloud*/
- /*drawhealth();
- displayitems();*/
- occumaster=0;
- /*DisableItem(gFileMenu,ABORT_ITEM);*/
-
- fromrect=multrect(58%8,58/8);
- torect=coorrect(width/2-80,height/2-10,32);
- fromrect.right+=128;
- torect.right+=128;
- CopyMask ((BitMapPtr)&(**pix3),&(bitmask3),&(*myWindow).portBits,
- &fromrect,&fromrect,&torect);
-
- while (masterstatus==STATUS_OVER)
- {
- HandleEvent();
- if(TickCount()<oldticks+2) timetest++;
- else timetest=0;
- while(TickCount()<oldticks+2) /*should be 2*/
- if (timetest>80)
- {
- timetest=0;
- addmoremon=TRUE;
- }
- oldticks=TickCount();
- testscroll();
- if (landscaperequest) landscape(level);
-
- objects();
- monsters();
- missiles();
- player();
- objects2();
- if(colororbw) SetPort((GrafPtr)myCGrafPtr);
- else SetPort(myGrafPtr);
- drawgameover();
- SetPort(myWindow);
-
- if (landscaperequest)
- {
- offtoon();
- landscaperequest=FALSE;
- }
- finaldraw();
- gcounter++;
- }
- }
- /**drawgameover**/
- drawgameover()
- {
- Rect fromrect,torect;
-
- fromrect=multrect(58%8,58/8);
- torect=coorrect(width/2-80,height/2-10,32);
- fromrect.right+=128;
- torect.right+=128;
-
- if(colororbw)
- CopyMask ((BitMapPtr)&(**pix3),&(bitmask3),(BitMapPtr)&myCGrafPtr->portPixMap,
- &fromrect,&fromrect,&torect);
- else
- CopyMask (&bit3,&(bitmask3),&myGrafPtr->portBits,
- &fromrect,&fromrect,&torect);
- }
-
-
-
- /*** HandleEvent ***/
-
- HandleEvent()
- {
- char theChar;
-
- WaitNextEvent(everyEvent,&gTheEvent,MIN_SLEEP,mousergn);
- switch(gTheEvent.what)
- {
- case mouseDown:
- HandleMouseDown();
- break;
- case keyDown:
- case autoKey:
- theChar=gTheEvent.message&charCodeMask;
- /*gtheChar=theChar;*/
- if((gTheEvent.modifiers&cmdKey)!=0)
- HandleMenuChoice(MenuKey(theChar));
- break;
- case keyUp:
- /*gtheChar=0;*/
- break;
- case updateEvt:
- if ((WindowPtr)gTheEvent.message==myWindow)
- {
- BeginUpdate((WindowPtr)gTheEvent.message);
- landscaperequest=TRUE;
- drawsidepanel();
- if (masterstatus==STATUS_WAIT) offtoon();
- EndUpdate((WindowPtr)gTheEvent.message);
- }
- break;
- case app4Evt:
- if(gTheEvent.message&0x01000000) /*suspend or resume*/
- {
- if(gTheEvent.message&0x00000001)
- {
- /*resume events*/
- }
- else
- {
- /*suspend event*/
- }
- }
- if((gTheEvent.message&0xff000000)==0xfa000000)
- maintaincursor(gTheEvent.where);
- }
- // if(gCallBackPerformed) disposea();
- }
-
- /*** HandleMouseDown ***/
- HandleMouseDown()
- {
- WindowPtr whichWindow;
- int thePart;
- long int menuChoice,windSize;
- Point p;
-
- thePart=FindWindow(gTheEvent.where,&whichWindow);
- switch(thePart)
- {
- case inMenuBar:
- menuChoice=MenuSelect(gTheEvent.where);
- HandleMenuChoice(menuChoice);
- break;
- case inSysWindow:
- SystemClick(&gTheEvent,whichWindow);
- break;
- case inDrag:
- DragWindow(whichWindow,gTheEvent.where,&gDragRect);
- setmousergn();
- break;
- case inGoAway:
- DisposeWindow(whichWindow);
- break;
- case inContent:
- p=gTheEvent.where;
- GlobalToLocal(&p);
- DoContent(p);
- break;
- }
- }
- /*** DoContent ***/
- DoContent(p)
- Point p;
- {
- int loop;
- long dummy;
-
- for(loop=0;loop<NUM_OF_BUTTONS;loop++)
- {
- if (PtInRect(p,&gbuttonrect[loop]))
- {
- DrawPicture(gbuttonpicd[loop],&gbuttonrect[loop]);
- while (Button() && PtInRect(p,&gbuttonrect[loop]))
- {
- WaitNextEvent(everyEvent,&gTheEvent,MIN_SLEEP,NIL_MOUSE_REGION);
- p=gTheEvent.where;
- GlobalToLocal(&p);
-
- }
- /*Delay(2,&dummy);*/
- /*check if user lifts button in orig rect*/
- if (PtInRect(p,&gbuttonrect[loop]))
- {
- switch (loop)
- {
- case 0: /*play*/
- masterstatus=STATUS_NEWGAME;
- break;
- case 1: /*pause*/
- pause();
- break;
- case 2: /*quit*/
- quitdialog();
- if(masterstatus==STATUS_QUIT)
- {
- level=0;
- soundkill();
- }
- break;
- case 3: /*help*/
- helpdialog();
- break;
- }
- }
- DrawPicture(gbuttonpicu[loop],&gbuttonrect[loop]);
- }
- }
- }
-
-
- /*** HandleMenuChoice ***/
- HandleMenuChoice(menuChoice)
- long int menuChoice;
- {
- int theMenu,theItem;
-
- if(menuChoice!=0)
- {
- theMenu=HiWord(menuChoice);
- theItem=LoWord(menuChoice);
- switch(theMenu)
- {
- case APPLE_MENU_ID:
- HandleAppleChoice(theItem);
- break;
- case FILE_MENU_ID:
- HandleFileChoice(theItem);
- break;
- case OPTIONS_MENU_ID:
- HandleOptionsChoice(theItem);
- break;
- case SIZE_MENU_ID:
- HandleSizeChoice(theItem);
- break;
- case MISC_MENU_ID:
- HandleMiscChoice(theItem);
- break;
- case START_MENU_ID:
- HandleStartChoice(theItem);
- break;
- case CONTROL_MENU_ID:
- HandleControlChoice(theItem);
- break;
- }
- HiliteMenu(0);
- }
- }
-
-
- /*** HandleAppleChoice ***/
-
- HandleAppleChoice(theItem)
- int theItem;
- {
- Str255 accName;
- int accNumber;
- int itemNumber;
- DialogPtr AboutDialog;
-
- switch(theItem)
- {
- case ABOUT_ITEM:
- /*NoteAlert(ABOUT_ALERT,NIL_POINTER);*/
- helpdialog();
- break;
- default:
- GetItem(gAppleMenu,theItem,accName);
- accNumber=OpenDeskAcc(accName);
- break;
- }
- }
-
- /*** HandleFileChoice ***/
- HandleFileChoice(theItem)
- int theItem;
- {
- switch(theItem)
- {
- case ABORT_ITEM:
- masterstatus=STATUS_OVER;
- /*level=0;*/
- break;
- case QUIT_ITEM:
- quitdialog();
- break;
- case NEW_ITEM:
- masterstatus=STATUS_NEWGAME;
- break;
- }
- }
-
- /*** HandleOptionsChoice ***/
- HandleOptionsChoice(theItem)
- int theItem;
- {
- switch(theItem)
- {
- case SOUND_ITEM:
- if(soundison)
- {
- CheckItem(gOptionsMenu,SOUND_ITEM,FALSE);
- soundison=FALSE;
- soundkill();
- break;
- }
- else
- {
- CheckItem(gOptionsMenu,SOUND_ITEM,TRUE);
- soundison=TRUE;
- break;
- }
- }
- }
- soundkill()
- {
- SndCommand mycommand;
-
- mycommand.cmd=quietCmd;
- if(gsndchannela==NIL) return;
- if(SndDoImmediate(gsndchannela,&mycommand))
- DoAlert("\pError in snd channel cmd");
- }
-
- /*** HandleSizeChoice***/
- HandleSizeChoice(theItem)
- int theItem;
- {
- int loop;
-
- switch(theItem)
- {
- case NATURAL_ITEM:
- lwidth=natlwidth;
- lheight=natlheight;
- break;
- case THE10BY10_ITEM:
- lwidth=10;
- lheight=10;
- break;
- case THE12BY12_ITEM:
- lwidth=12;
- lheight=12;
- break;
- case THE14BY13_ITEM:
- lwidth=14;
- lheight=13;
- break;
-
- }
- CheckItem(gSizeMenu,sizecheck,FALSE);
- CheckItem(gSizeMenu,theItem,TRUE);
- sizecheck=theItem;
- sizeset();
- if (lmapx>MAXLWIDTH-lwidth) lmapx=MAXLWIDTH-lwidth;
- mapx=lmapx*32;
- if (lmapy>MAXLHEIGHT-lheight) lmapy=MAXLHEIGHT-lheight;
- mapy=lmapy*32;
- SizeWindow(myWindow,width+192,height,TRUE);
- for (loop=0;loop<NUM_OF_BUTTONS;loop++)
- {
- gbuttonrect[loop].left=width+32+loop*32;
- gbuttonrect[loop].top=256;
- gbuttonrect[loop].right=width+64+loop*32;
- gbuttonrect[loop].bottom=256+32;
- }
- setmousergn();
- landscaperequest=TRUE;
- drawsidepanel();
- }
- /*** HandleStartChoice***/
- HandleStartChoice(theItem)
- int theItem;
- {
- CheckItem(gStartMenu,startlevel,FALSE);
- CheckItem(gStartMenu,theItem,TRUE);
- startlevel=theItem;
- }
- /*** HandleControlChoice***/
- HandleControlChoice(theItem)
- int theItem;
- {
- if(theItem==1) /*keyboard*/
- {
- CheckItem(gControlMenu,1,TRUE);
- CheckItem(gControlMenu,2,FALSE);
- gkeyormouse=FALSE;
- }
- if(theItem==2) /*mouse*/
- {
- CheckItem(gControlMenu,2,TRUE);
- CheckItem(gControlMenu,1,FALSE);
- gkeyormouse=TRUE;
- }
- maintaincursor(gTheEvent.where);
- }
- /*** HandleMiscChoice ***/
- HandleMiscChoice(theItem)
- int theItem;
- {
- switch(theItem)
- {
- case PAUSE_ITEM:
- pause();
- break;
- case INSTRUCT_ITEM:
- helpdialog();
- break;
- }
- }
- /**pause**/
- pause()
- {
- long dummy;
-
- if(masterstatus!=STATUS_GAME) return;
- ObscureCursor();
- soundkill();
- ontooff();
- TextFont(1);
- TextSize(64);
- TextMode(srcOr);
- MoveTo(width/2-80,height/2+20);
- Delay(20,&dummy);
- WaitNextEvent(everyEvent,&gTheEvent,6,mousergn);
- while (gTheEvent.what!=mouseDown&&gTheEvent.what!=keyDown)
- {
- WaitNextEvent(everyEvent,&gTheEvent,6,mousergn);
- ObscureCursor();
- if (TickCount()&0x00000020)
- {
- MoveTo(width/2-80,height/2+20);
- ForeColor(greenColor);
- if(level==11)
- ForeColor(yellowColor);
- DrawString("\pPause");
- ForeColor(blackColor);
- }
- else offtoon();
-
- }
- landscaperequest=TRUE;
- offtoon();
- ForeColor(blackColor);
- }
-
-
-
- /***maintaincursor***/
- /*checks positions of cursor and makes appropriate changes
- according to position*/
- maintaincursor(mypoint)
- Point mypoint;
- {
- if (PtInRect(mypoint,&trueplayrect)&&gkeyormouse)
- SetCursor(*gtargetcursor);
- }
-
-
- /**** Initialization subroutines ****/
- /*** ToolBoxInit ***/
- ToolBoxInit()
- {
- InitGraf(&qd.thePort);
- InitFonts();
- FlushEvents(everyEvent, REMOVE_ALL_EVENTS);
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(NIL_POINTER);
- InitCursor();
- }
-
- /*** WindowInit ***/
- WindowInit()
- {
- if (IsColor())
- {
- colororbw=TRUE;
- gbasepic=500;
- openpixmaps();
- }
- else
- {
- colororbw=FALSE;
- gbasepic=600;
- openbitmaps();
- }
- }
- /**openpixmaps**/
- openpixmaps()
- {
- Point tempP;
- Rect r;
- CTabHandle ourCMHandle;
- Handle dumbhandle;
- PaletteHandle mypalettehandle;
- long offRowBytes,sizeOfOff;
- int theDepth;
-
-
- sizeinit();
- myWindow=NewCWindow(NIL,&allrect,"\pLegend",VISIBLE,noGrowDocProc,
- (WindowPtr)MOVE_TO_FRONT,TRUE,NIL_REF_CON);
- mypalettehandle=GetNewPalette(BASE_RES_ID);
- SetPalette(myWindow,mypalettehandle,FALSE);
- DisposePalette(mypalettehandle);
-
- if(!SectRect(&(*myWindow).portRect,&playrect,&globRect))
- ExitToShell(); /* ? */
- tempP.v=globRect.top;
- tempP.h=globRect.left;
- LocalToGlobal(&tempP);
- globRect.top=tempP.v;
- globRect.left=tempP.h;
- tempP.v=globRect.bottom;
- tempP.h=globRect.right;
- LocalToGlobal(&tempP);
- globRect.bottom=tempP.v;
- globRect.right=tempP.h;
- theMaxDevice=GetMaxDevice(&globRect);
- oldDevice=GetGDevice();
- SetGDevice(theMaxDevice);
-
- myCGrafPtr=&myCGrafPort; /*create off screen bitmap*/
- OpenCPort(myCGrafPtr);
- theDepth=(**(*myCGrafPtr).portPixMap).pixelSize;
- offRowBytes=(((theDepth * (width))+15)>>5)<<2;
- sizeOfOff=(long)(height) *offRowBytes;
-
- mypiximage0=NewPtr(sizeOfOff); /*main offscreen bitimage*/
- (**(*myCGrafPtr).portPixMap).rowBytes=offRowBytes+0x8000;
- (**(*myCGrafPtr).portPixMap).bounds=playrect;
- (**(*myCGrafPtr).portPixMap).baseAddr=mypiximage0;
- dumbhandle=(Handle)(**(**theMaxDevice).gdPMap).pmTable;
- err=HandToHand(&dumbhandle);
- ourCMHandle=(CTabHandle)dumbhandle;
- for(i=0;i<=(**ourCMHandle).ctSize;++i)
- (**ourCMHandle).ctTable[i].value=i;
- (**ourCMHandle).ctFlags&=0x7ffff;
- /*(**ourCMHandle).ctSeed=GetCTSeed();*/
- /* this code is necessary for converting GDevice cluts to Pixmap cluts */
- (**(*myCGrafPtr).portPixMap).pmTable=ourCMHandle;
-
- mypiximage1=NewPtr(sizeOfOff); /*background bitimage*/
- if (!mypiximage1) DoAlert("\pI think we have a memory problem in mypiximage1");
- pix1=NewPixMap(); /*create pix1 pixmap*/
- CopyPixMap(myCGrafPtr->portPixMap,pix1);
- (**pix1).baseAddr=mypiximage1;
-
- offRowBytes=(((theDepth * (256))+15)>>4)<<1;
- sizeOfOff=(long)(256) *offRowBytes;
- mypiximage2=NewPtr(sizeOfOff); /*2nd bitimage*/
- if (!mypiximage2) DoAlert("\pI think we have a memory problem in mypiximage2");
- pix2=NewPixMap(); /*create pix2 pixmap*/
- CopyPixMap(myCGrafPtr->portPixMap,pix2);
- (**pix2).baseAddr=mypiximage2;
- (**pix2).rowBytes=offRowBytes+0x8000;
- (**pix2).bounds=sqRect;
-
-
- mypiximage3=NewPtr(sizeOfOff); /*3rd bitimage*/
- if (!mypiximage3) DoAlert("\pI think we have a memory problem in mypiximage3");
- pix3=NewPixMap(); /*create pix3 pixmap*/
- CopyPixMap(pix2,pix3);
- (**pix3).baseAddr=mypiximage3;
-
- mypiximage4=NewPtr(sizeOfOff); /*4th bitimage*/
- if (!mypiximage4) DoAlert("\pI think we have a memory problem in mypiximage3");
- pix4=NewPixMap(); /*create pix4 pixmap*/
- CopyPixMap(pix2,pix4);
- (**pix4).baseAddr=mypiximage4;
-
- bitmask3.baseAddr=NewPtr(8192); /*3rd bitimage mask*/
- bitmask3.rowBytes=32;
- SetRect(&r,0,0,256,256);
- bitmask3.bounds=r;
-
-
- bitmask4.baseAddr=NewPtr(8192); /*4th bitimage mask*/
- bitmask4.rowBytes=32;
- SetRect(&r,0,0,256,256);
- bitmask4.bounds=r;
-
-
- SetPort((GrafPtr)myCGrafPtr); /*draw pictures*/
- if(theDepth<=2) gbasepic=600;
- LDR(gbasepic+1,0,0);
- CopyBits((BitMapPtr)&myCGrafPtr->portPixMap,(BitMapPtr)&(**pix2),&sqRect,&sqRect,srcCopy,0l);
- LDR(502,0,0);
- CopyBits((BitMapPtr)&myCGrafPtr->portPixMap,(BitMapPtr)&(**pix3),&sqRect,&sqRect,srcCopy,0l);
- LDR(503,0,0);
- CopyBits((BitMapPtr)&myCGrafPtr->portPixMap,(BitMapPtr)&(bitmask3),&sqRect,&sqRect,srcCopy,0l);
- LDR(504,0,0);
- CopyBits((BitMapPtr)&myCGrafPtr->portPixMap,(BitMapPtr)&(**pix4),&sqRect,&sqRect,srcCopy,0l);
- LDR(505,0,0);
- CopyBits((BitMapPtr)&myCGrafPtr->portPixMap,(BitMapPtr)&(bitmask4),&sqRect,&sqRect,srcCopy,0l);
- drawsidepanel();
-
-
- SetPort((WindowPtr)myWindow);
- SetGDevice(oldDevice);
- (**(*myCGrafPtr).portPixMap).baseAddr=mypiximage0;
-
- }
- /**openbitmaps**/
- openbitmaps()
- {
- long offRowBytes,sizeOfOff;
-
- sizeinit();
- myWindow=NewWindow(NIL,&allrect,"\pLegend",VISIBLE,noGrowDocProc,
- (WindowPtr)MOVE_TO_FRONT,TRUE,NIL_REF_CON);
-
- myGrafPtr=&myGrafPort; /*create off screen bitmap*/
- OpenPort(myGrafPtr);
- offRowBytes=((width+15)>>5)<<2;
- sizeOfOff=(long)(height)*offRowBytes;
-
- mybitimage0=NewPtr(sizeOfOff); /*main offscreen bitimage*/
- bit0.baseAddr=mybitimage0;
- bit0.rowBytes=offRowBytes;
- bit0.bounds=playrect;
- SetPortBits(&bit0);
-
- mybitimage1=NewPtr(sizeOfOff); /*background bitimage*/
- if (!mybitimage1) DoAlert("\pI think we have a memory problem in mybitimage1");
- bit1.baseAddr=mybitimage1;
- bit1.rowBytes=offRowBytes;
- bit1.bounds=playrect;
-
- mybitimage2=NewPtr(8192); /*2nd bitimage*/
- if (!mybitimage2) DoAlert("\pI think we have a memory problem in mybitimage2");
- bit2.baseAddr=mybitimage2;
- bit2.rowBytes=32;
- bit2.bounds=sqRect;
-
-
- mybitimage3=NewPtr(8192); /*3rd bitimage*/
- if (!mybitimage3) DoAlert("\pI think we have a memory problem in mybitimage3");
- bit3.baseAddr=mybitimage3;
- bit3.rowBytes=32;
- bit3.bounds=sqRect;
-
- mybitimage4=NewPtr(8192); /*4th bitimage*/
- if (!mybitimage4) DoAlert("\pI think we have a memory problem in mybitimage3");
- bit4.baseAddr=mybitimage4;
- bit4.rowBytes=32;
- bit4.bounds=sqRect;
-
- bitmask3.baseAddr=NewPtr(8192); /*3rd bitimage mask*/
- bitmask3.rowBytes=32;
- bitmask3.bounds=sqRect;
-
-
- bitmask4.baseAddr=NewPtr(8192); /*4th bitimage mask*/
- bitmask4.rowBytes=32;
- bitmask4.bounds=sqRect;
-
-
- SetPort(myGrafPtr); /*draw pictures*/
- LDR(601,0,0);
- CopyBits(&myGrafPtr->portBits,&bit2,&sqRect,&sqRect,srcCopy,0l);
- LDR(502,0,0);
- CopyBits(&myGrafPtr->portBits,&bit3,&sqRect,&sqRect,srcCopy,0l);
- LDR(503,0,0);
- CopyBits(&myGrafPtr->portBits,&(bitmask3),&sqRect,&sqRect,srcCopy,0l);
- LDR(504,0,0);
- CopyBits(&myGrafPtr->portBits,&(bit4),&sqRect,&sqRect,srcCopy,0l);
- LDR(505,0,0);
- CopyBits(&myGrafPtr->portBits,&(bitmask4),&sqRect,&sqRect,srcCopy,0l);
- drawsidepanel();
-
-
- SetPort((WindowPtr)myWindow);
- }
- /**drawsidepanel**/
- drawsidepanel()
- {
- int loop;
- Rect srcrect,destrect;
-
- SetPort(myWindow);
- LoadPicture(gbasepic);
- DrawMyPictureat(gThePicture,width,0);
- if (height>320) /*extend side panel if required*/
- {
- for (loop=320;loop<=height-32;loop+=32)
- {
- SetRect(&srcrect,width,224,width+192,256);
- SetRect(&destrect,width,loop,width+192,loop+32);
- CopyBits(&(*myWindow).portBits,&(*myWindow).portBits,&srcrect,
- &destrect,srcCopy,NIL);
- }
- }
- ReleaseResource((Handle)gThePicture);
- displayscore();
- drawhealth();
- displayitems();
- }
-
- /***sizeinit***/
- /*this routine finds the screen size and sets the game size*/
- sizeinit()
- {
- int top;
-
- if (qd.screenBits.bounds.bottom<=342)
- {
- top=qd.screenBits.bounds.top+GetMBarHeight();
- }
- else top=qd.screenBits.bounds.top+48;
- lwidth=(qd.screenBits.bounds.right-qd.screenBits.bounds.left-192)/32;
- lheight=(qd.screenBits.bounds.bottom-top)/32;
- if (lwidth>MAXLWIDTH) lwidth=MAXLWIDTH;
- if (lheight>MAXLHEIGHT) lheight=MAXLHEIGHT;
- natlwidth=lwidth;
- natlheight=lheight;
- playregion=NewRgn();
- sizeset();
- OffsetRect(&allrect,0,top);
- }
- /**sizeset**/
- sizeset()
- {
- width=lwidth*32;
- height=lheight*32;
- SetRect(&playrect,0,0,width,height);
- SetRect(&allrect,0,0,width+192,height);
- RectRgn(playregion,&playrect);
- }
-
- /*** SetUpDragRect ***/
- SetUpDragRect()
- {
- gDragRect=qd.screenBits.bounds;
- gDragRect.left+=DRAG_THRESHOLD;
- gDragRect.right-=DRAG_THRESHOLD;
- gDragRect.bottom-=DRAG_THRESHOLD;
- }
-
- /*** MenuBarInit ***/
-
- MenuBarInit()
- {
- Handle myMenuBar;
-
- myMenuBar=GetNewMBar(BASE_RES_ID);
- SetMenuBar(myMenuBar);
-
- gAppleMenu=GetMHandle(APPLE_MENU_ID);
- gFileMenu=GetMenu(FILE_MENU_ID);
- gOptionsMenu=GetMenu(OPTIONS_MENU_ID);
- gMiscMenu=GetMenu(MISC_MENU_ID);
- gSizeMenu=GetMenu(SIZE_MENU_ID);
- gStartMenu=GetMenu(START_MENU_ID);
- gControlMenu=GetMenu(CONTROL_MENU_ID);
-
- InsertMenu(gSizeMenu,NOT_A_NORMAL_MENU);
- InsertMenu(gStartMenu,NOT_A_NORMAL_MENU);
- InsertMenu(gControlMenu,NOT_A_NORMAL_MENU);
-
- AddResMenu(gAppleMenu,'DRVR');
- DrawMenuBar();
- }
-
- /*** MiscInit ***/
- MiscInit()
- {
- SetEventMask(everyEvent); /*allows key up events to be seen*/
- mousergn=NewRgn();
- setmousergn();
-
- if(IsIdle()) DisableIdle(); /*For PowerBook only!*/
-
- gsimplesound=TRUE;
- gsndchannela=NIL;
- gsndchannelb=NIL;
- gsndchannelc=NIL;
- if(SndNewChannel(&gsndchannela,0,0,NIL_POINTER)!=noErr)
- DoAlert("\pError allocating snd channela");
- if(!gsimplesound)
- {
- if(SndNewChannel(&gsndchannelb,0,0,NIL_POINTER)!=noErr)
- DoAlert("\pError allocating snd channelb");
- if(SndNewChannel(&gsndchannelc,0,0,NIL_POINTER)!=noErr)
- DoAlert("\pError allocating snd channelc");
- }
-
- tocattahandle=GetResource('snd ',TOCATTA_SND);
- yumhandle=GetResource('snd ',YUM_SND);
- foothandle=GetResource('snd ',FOOT_SND);
- arrowhandle=GetResource('snd ',ARROW_SND);
- ouchhandle=GetResource('snd ',OUCH_SND);
- keyhandle=GetResource('snd ',KEY_SND);
- moneyhandle=GetResource('snd ',MONEY_SND);
- bathandle=GetResource('snd ',BAT_SND);
- unlockhandle=GetResource('snd ',UNLOCK_SND);
- poofhandle=GetResource('snd ',POOF_SND);
- eephandle=GetResource('snd ',EEP_SND);
-
- HLock(tocattahandle);
- HLock(yumhandle);
- HLock(foothandle);
- HLock(arrowhandle);
- HLock(ouchhandle);
- HLock(keyhandle);
- HLock(moneyhandle);
- HLock(bathandle);
- HLock(unlockhandle);
- HLock(poofhandle);
- soundison=TRUE;
-
- gtargetcursor=GetCursor(400);
- /*SetCursor(*gtargetcursor);*/
-
- ForeColor(blackColor);
- BackColor(whiteColor);
-
- buttoninit();
-
- score=0;
- numfinal=0;
- health=healtht=88;
- startlevel=1;
- hlevel=2;
- drawhealth();
- }
- /**setmousergn**/
- /*sets the inactive mouse rgn for waitnextevent*/
- setmousergn()
- {
- DiffRgn(GetGrayRgn(),((WindowPeek)myWindow)->strucRgn,mousergn);
- trueplayrect.top=playrect.top;
- trueplayrect.left=playrect.left;
- trueplayrect.bottom=playrect.bottom;
- trueplayrect.right=playrect.right;
- LocalToGlobal(&topLeft(trueplayrect));
- LocalToGlobal(&botRight(trueplayrect));
- }
- /*** ButtonInit ***/
- buttoninit()
- {
- int loop;
- Byte picu[NUM_OF_BUTTONS]={10,12,14,16};
- Byte picd[NUM_OF_BUTTONS]={11,13,15,17};
-
- for (loop=0;loop<NUM_OF_BUTTONS;loop++)
- {
- gbuttonpicu[loop]=GetPicture(picu[loop]+gbasepic);
- gbuttonpicd[loop]=GetPicture(picd[loop]+gbasepic);
- gbuttonrect[loop].left=width+32+loop*32;
- gbuttonrect[loop].top=256;
- gbuttonrect[loop].right=width+64+loop*32;
- gbuttonrect[loop].bottom=256+32;
- }
- }
-
-
- /***cleanup***/
- /*last stuff before exiting*/
- cleanup()
- {
- /*if(SndDisposeChannel(gsndchannela,TRUE)!=noErr)
- DoAlert("\pInvalid channel queue length");
- if(!gsimplesound)
- {
- if(SndDisposeChannel(gsndchannelb,TRUE)!=noErr)
- DoAlert("\pInvalid channel queue length");
- if(SndDisposeChannel(gsndchannelc,TRUE)!=noErr)
- DoAlert("\pInvalid channel queue length");
- }
- */
- if(IsIdle()) EnableIdle(); /*For PowerBook only!*/
- }
-
-
- /**** Misc Subroutines ****/
- /*** IsColor ***/
- Boolean IsColor()
- {
- SysEnvRec mySE;
- SysEnvirons(2,&mySE);
- return(mySE.hasColorQD);
- /*return(FALSE);*/
- }
- /*** IsIdle ***/
- /* checks to see if idle is available in portable computers*/
- Boolean IsIdle()
- {
- OSErr gestalterr;
- long response;
- gestalterr=Gestalt('powr',&response);
- if (!gestalterr && (response&1)) return(TRUE);
- else return(FALSE);
- }
-
- /*** LoadPicture ***/
- LoadPicture(picnum)
- int picnum;
- {
- gThePicture=GetPicture(picnum);
- }
-
- DrawMyPicture(thePicture)
- PicHandle thePicture;
- {
- Rect myRect,pictureRect;
- pictureRect=(**(thePicture)).picFrame;
- myRect.top=0;
- myRect.bottom=(pictureRect.bottom-pictureRect.top);
- myRect.left=0;
- myRect.right=(pictureRect.right-pictureRect.left);
- DrawPicture(thePicture,&myRect);
- }
-
- /*** LDR ***/
- /*load, draw, and release picture
- requires a resource #of a pict*/
- LDR(picnum,x,y)
- int picnum,x,y;
- {
- PicHandle ThePicture;
-
- ThePicture=GetPicture(picnum);
- DrawMyPictureat(ThePicture,x,y);
- ReleaseResource((Handle)ThePicture);
- }
- /***DrawMyPictureat***/
- /*similar to LDR but requires a pichandle*/
- DrawMyPictureat(thePicture,x,y)
- PicHandle thePicture;
- int x,y;
- {
- Rect myRect,pictureRect;
-
- pictureRect=(**(thePicture)).picFrame;
- myRect.top=y;
- myRect.bottom=(y+pictureRect.bottom-pictureRect.top);
- myRect.left=x;
- myRect.right=(x+pictureRect.right-pictureRect.left);
- DrawPicture(thePicture,&myRect);
- }
-
-
-
- /***Sounder***/
- sounder(mysndchan,mysoundhandle)
- SndChannelPtr mysndchan;
- Handle mysoundhandle;
-
- {
- SndCommand mycommand;
-
- if (soundison&&masterstatus!=STATUS_OVER)
- {
- if(gsimplesound)
- mysndchan=gsndchannela;
- mycommand.cmd=flushCmd;
- mycommand.param1=0;
- mycommand.param2=0;
- if(SndDoImmediate(mysndchan,&mycommand))
- DoAlert("\pError in snd channel cmd");
- mycommand.cmd=quietCmd;
- if(SndDoImmediate(mysndchan,&mycommand))
- DoAlert("\pError in snd channel cmd");
-
- if(SndPlay(mysndchan,mysoundhandle,TRUE))
- DoAlert("\pError in SndPlay");
- }
- }
-
- /***Randomize***/
- /* takes a number and will return a value between zero and range-1 */
- Randomize(range)
- int range;
- {
- long rawresult;
- rawresult=Random();
- if(rawresult<0) rawresult *=-1;
- return((rawresult*range)/32768);
- }
-
- /***Landscape***/
- /* takes a level and creates the appropriate landscape in the main offscreen
- bitmap AND the background bitmap*/
- landscape(level)
- int level;
- {
- Rect fromrect,torect;
- int row,column;
-
- for(column=0;column<lwidth;column++)
- for(row=0;row<lheight;row++)
- {
- fromrect=multrect(thislevel[row+lmapy][column+lmapx]%8,
- thislevel[row+lmapy][column+lmapx]/8);
- torect=(multrect(column,row));
- if (colororbw)
- CopyBits((BitMapPtr)&(**pix2),(BitMapPtr)&myCGrafPtr->portPixMap,
- &fromrect,&torect,srcCopy,0L);
- else
- CopyBits(&bit2,&myGrafPtr->portBits,
- &fromrect,&torect,srcCopy,0L);
- }
- if(colororbw)
- CopyBits((BitMapPtr)&myCGrafPtr->portPixMap,(BitMapPtr)&(**pix1),
- &playrect,&playrect,srcCopy,0L);
- else
- CopyBits(&myGrafPtr->portBits,&bit1,
- &playrect,&playrect,srcCopy,0L);
- }
- /**displayscore**/
- /*also checks if the player gets bonus icecream cone*/
- displayscore()
- {
- int loop,number;
- Rect fromrect,torect;
-
- convertscore();
- for (loop=3;loop>=0;loop--)
- {
- number=digit[loop];
- SetRect(&fromrect,96+number*16,224,112+number*16,256);
- SetRect(&torect,width+96-loop*16,64,width+112-loop*16,96);
- if (colororbw)
- CopyBits((BitMapPtr)&(**pix2),&(*myWindow).portBits,
- &fromrect,&torect,srcCopy,0L);
- else
- CopyBits(&bit2,&(*myWindow).portBits,
- &fromrect,&torect,srcCopy,0L);
- }
- if(gbonuselg && digit[1]<=1 && (digit[2]&1)==0)
- { /*player has earned icecream*/
- gbonuselg=FALSE;
- addmoremon=FALSE;
- nummonsters++;
- monster[nummonsters].status=ICECREAM;
- monster[nummonsters].dir=0;
- monster[nummonsters].x=0;
- if (plx>MAXLWIDTH*16)
- {
- monster[nummonsters].dir=1;
- monster[nummonsters].x=MAXLWIDTH*32;
- }
- monster[nummonsters].y=ply;
- monster[nummonsters].transit=0;
- }
- else if (digit[1]>=8) gbonuselg=TRUE; /*reset*/
- }
- /**convertscore**/
- convertscore()
- {
- register int temp;
-
- temp=score;
- digit[3]=temp/1000;
- temp-=digit[3]*1000;
- digit[2]=temp/100;
- temp-=digit[2]*100;
- digit[1]=temp/10;
- temp-=digit[1]*10;
- digit[0]=temp;
- }
- /**displayhealth**/
- displayhealth()
- {
- Rect fromrect,torect;
- int whichbar;
-
- if (health<healtht)
- {
- health++;
- if (health<healtht-16) health++;
- }
- if (health>healtht) health--;
-
- if (health>32)
- {
- fromrect=minimultrect(1,14);
- torect.left=width+health+16;
- torect.top=128;
- torect.right=width+health+32;
- torect.bottom=144;
- }
- else
- {
- if(health<2)
- {
- health=2;
- masterstatus=STATUS_OVER;
- }
- if(gred&&(health<30)) whichbar=240;
- else whichbar=224;
- SetRect(&fromrect,33-health,whichbar,32,whichbar+16);
- SetRect(&torect,width+33,128,width+32+health,144);
- }
- if (colororbw)
- CopyBits((BitMapPtr)&(**pix2),&(*myWindow).portBits,
- &fromrect,&torect,srcCopy,0L);
- else
- CopyBits(&bit2,&(*myWindow).portBits,
- &fromrect,&torect,srcCopy,0L);
- }
- /**drawhealth**/
- /*draws health bar from cleared state*/
- drawhealth()
- {
- Rect fromrect,torect;
- register int loop;
-
- if(health>32)
- {
- fromrect=minimultrect(0,14);
- torect=coorrect(width+32,128,16);
- if (colororbw)
- CopyBits((BitMapPtr)&(**pix2),&(*myWindow).portBits,
- &fromrect,&torect,srcCopy,0L);
- else
- CopyBits(&bit2,&(*myWindow).portBits,
- &fromrect,&torect,srcCopy,0L);
- fromrect=minimultrect(1,14);
-
- for(loop=32;loop<=health;loop+=8)
- {
- torect=coorrect(width+16+loop,128,16);
- if (colororbw)
- CopyBits((BitMapPtr)&(**pix2),&(*myWindow).portBits,
- &fromrect,&torect,srcCopy,0L);
- else
- CopyBits(&bit2,&(*myWindow).portBits,
- &fromrect,&torect,srcCopy,0L);
- }
- }
- displayhealth();
- }
- /***displayitems***/
- /*draws items in gitemlist[n]*/
- displayitems()
- {
- int loop,mypict;
- Rect fromrect,torect;
-
- gitemlist[gnumitems]=0; /*clear this space so it draws clear*/
- for(loop=0;loop<=gnumitems;loop++)
- {
- mypict=gitempic[gitemlist[loop]];
- fromrect=minimultrect((mypict&15),mypict>>4);
- torect=coorrect(width+48+loop*16,176,16);
- if (colororbw)
- CopyBits((BitMapPtr)&(**pix2),&(*myWindow).portBits,
- &fromrect,&torect,srcCopy,0L);
- else
- CopyBits(&bit2,&(*myWindow).portBits,
- &fromrect,&torect,srcCopy,0L);
- }
- }
- /**searchitems**/
- /*takes item code and returns with item number with matching code
- if nothing matches this returns -1*/
- int searchitems(int findme)
- {
- int loop,result;
-
- result=-1;
- for(loop=0;loop<gnumitems;loop++)
- if(gitemlist[loop]==findme) result=loop;
- return(result);
- }
- /*removeitem*/
- /*takes an item number of removes it from the list*/
- removeitem(removeme)
- int removeme;
- {
- int loop;
-
- gnumitems--;
- if (removeme<gnumitems)
- for(loop=removeme;loop<gnumitems;loop++)
- gitemlist[loop]=gitemlist[loop+1];
- displayitems();
- }
-
-
-
- /***pldraw***/
- pldraw()
- {
- Rect fromrect,torect;
-
- fromrect=multrect(plp%8,plp/8);
- torect=coorrect(plx-mapx,ply-mapy,32);
-
- if(colororbw)
- CopyMask ((BitMapPtr)&(**pix3),&(bitmask3),(BitMapPtr)&myCGrafPtr->portPixMap,
- &fromrect,&fromrect,&torect);
- else
- CopyMask (&bit3,&(bitmask3),&myGrafPtr->portBits,
- &fromrect,&fromrect,&torect);
-
- finals[numfinal].x=plx-mapx;
- finals[numfinal].y=ply-mapy;
- finals[numfinal].size=32;
- numfinal++;
- }
- /***objectdraw***/
- objectdraw(pic,x,y)
- int pic,x,y;
- {
- Rect fromrect,torect;
-
- fromrect=multrect(pic&7,pic>>3);
- torect=coorrect(x-mapx,y-mapy,32);
- if(colororbw)
- {
- CopyBits((BitMapPtr)&(**pix2),(BitMapPtr)&myCGrafPtr->portPixMap,
- &fromrect,&torect,srcCopy,0L);
- CopyBits((BitMapPtr)&(**pix2),(BitMapPtr)&(**pix1),
- &fromrect,&torect,srcCopy,0L);
- }
- else
- {
- CopyBits(&bit2,&myGrafPtr->portBits,
- &fromrect,&torect,srcCopy,0L);
- CopyBits(&bit2,&bit1,
- &fromrect,&torect,srcCopy,0L);
- }
- finals[numfinal].x=x-mapx;
- finals[numfinal].y=y-mapy;
- finals[numfinal].size=32;
- numfinal++;
- }
- /***overdraw***/
- /*this routine is intended to draw last objects on top*/
- overdraw(pic,x,y)
- int pic,x,y;
- {
- Rect fromrect,torect;
-
- fromrect=multrect(pic&7,pic>>3);
- torect=coorrect(x-mapx,y-mapy,32);
- if(colororbw)
- {
- CopyBits((BitMapPtr)&(**pix2),(BitMapPtr)&myCGrafPtr->portPixMap,
- &fromrect,&torect,srcCopy,0L);
- }
- else
- {
- CopyBits(&bit2,&myGrafPtr->portBits,
- &fromrect,&torect,srcCopy,0L);
- }
- }
- /***mondraw***/
- mondraw(pic,x,y)
- int pic;
- register int x,y;
- {
- Rect fromrect,torect;
-
- fromrect=multrect(pic&7,pic>>3);
- torect.left=finals[numfinal].x=x-mapx; /*i.e. coorrect*/
- torect.top=finals[numfinal].y=y-mapy;
- torect.right=x-mapx+32;
- torect.bottom=y-mapy+32;
- if(colororbw)
- CopyMask ((BitMapPtr)&(**pix4),&(bitmask4),(BitMapPtr)&myCGrafPtr->portPixMap,
- &fromrect,&fromrect,&torect);
- else
- CopyMask (&bit4,&(bitmask4),&myGrafPtr->portBits,
- &fromrect,&fromrect,&torect);
-
- /*finals[numfinal].x=x-mapx;
- finals[numfinal].y=y-mapy; moved above*/
- finals[numfinal].size=32;
- numfinal++;
- }
- /***minidraw***/
- minidraw(pic,x,y)
- int pic;
- register int x,y;
- {
- Rect fromrect,torect;
-
- SetRect(&fromrect,(pic&15)*16,(pic>>4)*16,
- (pic&15)*16+16,(pic>>4)*16+16); /*minimult*/
- torect.left=x-mapx; /*i.e. coorrect*/
- torect.top=y-mapy;
- torect.right=x-mapx+16;
- torect.bottom=y-mapy+16;
-
- if(colororbw)
- CopyMask ((BitMapPtr)&(**pix4),&(bitmask4),(BitMapPtr)&myCGrafPtr->portPixMap,
- &fromrect,&fromrect,&torect);
- else
- CopyMask (&bit4,&(bitmask4),&myGrafPtr->portBits,
- &fromrect,&fromrect,&torect);
-
- finals[numfinal].x=x-mapx;
- finals[numfinal].y=y-mapy;
- finals[numfinal].size=16;
- numfinal++;
- }
- /***dotdraw***/
- dotdraw(x,y)
- register int x,y;
- {
- Rect torect;
- Pattern thePat; /* added for calls GetIndPattern and FillRect */
-
- torect.left=x-mapx; /*i.e. coorrect*/
- torect.top=y-mapy;
- torect.right=x-mapx+4;
- torect.bottom=y-mapy+4;
-
- if(colororbw) SetPort((GrafPtr)myCGrafPtr);
- else SetPort(myGrafPtr);
-
- GetIndPattern( &thePat, sysPatListID, 1 ); /* system pattern - black */
- FillRect (&torect, &thePat); //bsk
- SetPort(myWindow);
-
- finals[numfinal].x=x-mapx;
- finals[numfinal].y=y-mapy;
- finals[numfinal].size=4;
- numfinal++;
- }
-
-
- /***Final Draw***/
- /*this routine steps through all the final transfers. the coordinates
- are in window coornates (i.e. map x and mapy should alread be accounted
- for)*/
- finaldraw()
- {
- register int count;
- Rect myrect;
-
- SetPort(myWindow);
- if(colororbw)
- {
- for (count=0;count<numfinal;count++)
- {
- /*i.e. coorrectl*/
- myrect.left=finals[count].x-2;
- myrect.top=finals[count].y-2;
- myrect.right=finals[count].x+finals[count].size+4;
- myrect.bottom=finals[count].y+finals[count].size+4;
- CopyBits((BitMapPtr)&myCGrafPtr->portPixMap,&(*myWindow).portBits,
- &myrect,&myrect,0,playregion);
- }
- for (count=0;count<numfinal;count++)
- {
- /*i.e. coorrect*/
- myrect.left=finals[count].x;
- myrect.top=finals[count].y;
- myrect.right=finals[count].x+finals[count].size;
- myrect.bottom=finals[count].y+finals[count].size;
- CopyBits((BitMapPtr)&**(pix1),(BitMapPtr)&myCGrafPtr->portPixMap,
- &myrect,&myrect,srcCopy,0L);
- }
- }
- else
- {
- for (count=0;count<numfinal;count++)
- {
- /*i.e. coorrectl*/
- myrect.left=(finals[count].x-2)&65528;
- myrect.top=finals[count].y-2;
- myrect.right=(finals[count].x+finals[count].size+11)&65528;
- myrect.bottom=finals[count].y+finals[count].size+4;
- CopyBits(&myGrafPtr->portBits,&(*myWindow).portBits,
- &myrect,&myrect,0,playregion);
- }
- for (count=0;count<numfinal;count++)
- {
- /*i.e. coorrect*/
- myrect.left=(finals[count].x)&65528;
- myrect.top=finals[count].y;
- myrect.right=(finals[count].x+finals[count].size+7)&65528;
- myrect.bottom=finals[count].y+finals[count].size;
- CopyBits(&bit1,&myGrafPtr->portBits,
- &myrect,&myrect,srcCopy,0L);
- }
- }
-
- numfinal=0;
- }
-
- /***multrect***/
- /* takes landscape coordinates and converts to rect based on 32 */
- Rect multrect(x,y)
- register int x,y;
- {
- Rect r;
-
- SetRect(&r,x*32,y*32,x*32+32,y*32+32);
- return(r);
- }
- /***minimultrect***/
- /* takes landscape coordinates and converts to rect based on 16 */
- Rect minimultrect(x,y)
- register int x,y;
- {
- Rect r;
-
- SetRect(&r,x*16,y*16,x*16+16,y*16+16);
- return(r);
- }
-
- /***coorrect***/
- /* takes a coordinate and returns the rect based on 32*/
- /*i.e. SetRect(&r,x,y,x+size,y+size)*/
- Rect coorrect(x,y,size)
- register int x,y,size;
- {
- Rect r;
-
- r.left=x;
- r.top=y;
- r.right=x+size;
- r.bottom=y+size;
- return(r);
- }
-
- /***coorrectl***/
- /* takes a coordinate and returns the larger rect*/
- Rect coorrectl(x,y,size)
- int x,y,size;
- {
- Rect r;
-
- r.left=x-2;
- r.top=y-2;
- r.right=x+size+4;
- r.bottom=y+size+4;
- return(r);
- }
-
-
- /***makebitmap***/
- /*set bit map stuff in fields*/
- BitMap makebitmap()
- {
- Rect r;
- BitMap mymap;
-
- mymap.baseAddr=NewPtr(8192);
- mymap.rowBytes=32;
- SetRect(&r,0,0,256,256);
- mymap.bounds=r;
- return(mymap);
- }
-
- /*** DoAlert ***/
- DoAlert(s)
- Str255 s;
- {
- ParamText(s,NIL_STRING,NIL_STRING,NIL_STRING);
- NoteAlert(401,NIL_POINTER);
- ExitToShell();
- }
-
- /***setlevel***/
- setlevel(level)
- int level;
- {
- int column,row;
-
- lmapx=0;
- lmapy=0;
- mapx=lmapx*32;
- mapy=lmapy*32;
-
- for(column=0;column<24;column++)
- for(row=0;row<16;row++) /* 18? */
- thislevel[row][column]=dungeon[level][row][column];
- for(column=0;column<4;column++) /*clear(lock) all gates*/
- gatestatus[column]=0;
- landscaperequest=faderequest=TRUE;
- datainit();
- playerinit();
- ObscureCursor();
- }
- /**offtoon**/
- /*copies the bit image info from offscreen to on*/
- offtoon()
- {
- if(colororbw)
- CopyBits((BitMapPtr)&myCGrafPtr->portPixMap,&(*myWindow).portBits,
- &playrect,&playrect,0,NIL_POINTER);
- else
- CopyBits(&myGrafPtr->portBits,&(*myWindow).portBits,
- &playrect,&playrect,0,NIL_POINTER);
-
- }
- /**ontooff**/
- /*copies the bit image info from offscreen to on*/
- ontooff()
- {
- if(colororbw)
- CopyBits(&(*myWindow).portBits,(BitMapPtr)&myCGrafPtr->portPixMap,
- &playrect,&playrect,0,NIL_POINTER);
- else
- CopyBits(&(*myWindow).portBits,&myGrafPtr->portBits,
- &playrect,&playrect,0,NIL_POINTER);
-
- }
- /**playerinit**/
- playerinit()
- {
- pls=plt=pld=0;
- plx=32*startx[level];
- ply=32*starty[level];
- plp=8;
- }
- /**datainit**/
- /* converts all the data stored in data arrays into proper structures*/
- datainit()
- {
- int loop;
-
- for (loop=0;loop<MAXMONSTERS;loop++)
- monster[loop].status=0;
- for (loop=0;loop<MAXMISSILES;loop++)
- missile[loop].status=3;
- missile[0].status=0;
-
- numobjects=nummonsters=0;
- for (loop=0;loop<MAXOBJECTS;loop++)
- {
- if (data[level][loop][4]==1)
- {
- /*it's an object!*/
- object[numobjects].status=data[level][loop][0];
- object[numobjects].dir=data[level][loop][1];
- object[numobjects].x=data[level][loop][2]*32;
- object[numobjects].y=data[level][loop][3]*32;
- object[numobjects].transit=0;
- object[numobjects].pic=data[level][loop][5];
- object[numobjects].alt1=data[level][loop][6];
- object[numobjects].alt2=data[level][loop][7];
- numobjects++;
- }
- else if(data[level][loop][4]==2)
- {
- /*it's a monster*/
- monster[nummonsters].status=data[level][loop][0];
- monster[nummonsters].dir=data[level][loop][1];
- monster[nummonsters].x=data[level][loop][2]*32;
- monster[nummonsters].y=data[level][loop][3]*32;
- monster[nummonsters].transit=0;
- monster[nummonsters].pic=data[level][loop][5]*32;
- monster[nummonsters].alt1=data[level][loop][6]*32;
- monster[nummonsters].alt2=data[level][loop][7]*32;
- nummonsters++;
- }
- }
- }
-
-
-
- /***testscroll***/
- testscroll()
- {
- if (plx-mapx>width-64) scrollleft();
- if (plx-mapx<32) scrollright();
- if (ply-mapy>height-64) scrollup();
- if (ply-mapy<32) scrolldown();
- }
- scrollleft()
- {
- int oldlmapx;
-
- oldlmapx=lmapx;
- lmapx=lmapx+lwidth-3;
- if (lmapx>24-lwidth) lmapx=24-lwidth;
- mapx=lmapx*32;
- if(lmapx!=oldlmapx) landscaperequest=TRUE; /*if no change then no landscape*/
- }
- scrollright()
- {
- int oldlmapx;
-
- oldlmapx=lmapx;
- lmapx=lmapx-lwidth+3;
- if(lmapx<0) lmapx=0;
- mapx=lmapx*32;
- if(lmapx!=oldlmapx) landscaperequest=TRUE; /*if no change then no landscape*/
- }
- scrollup()
- {
- lmapy=lmapy+lheight-3;
- if (lmapy>16-lheight) lmapy=16-lheight;
- mapy=lmapy*32;
- landscaperequest=TRUE;
- }
- scrolldown()
- {
- lmapy=lmapy-lheight+3;
- if(lmapy<0)lmapy=0;
- mapy=lmapy*32;
- landscaperequest=TRUE;
- }
-
- /***player***/
- player()
- {
- int temp;
-
- ploccuset(); /*modify occuvalues here*/
- switch(pls)
- {
- case 0: /*wait*/
- temp=keydir();
- if (temp>-1)
- {
- pls=4;
- pld=temp;
- plt=0;
- }
- break;
- case 4: /*walk*/
- plp=plwalkpic[pld][plt];
- plt++;
- if (plt>9) plt=0;
- if(!gsimplesound)
- {
- if(plt==3) sounder(gsndchannela,foothandle);
- if(plt==8) sounder(gsndchannelb,foothandle);
- }
- occumaster=2;
- if(gkeyormouse) cango2(&plx,&ply,dir2x[pld],dir2y[pld],pld,31);
- else cango(&plx,&ply,dir2x[pld],dir2y[pld],pld,31);
- temp=keydir();
- if (temp==pld) break;
- if (temp<0)
- {
- pls=plt=0;
- break;
- }
- pld=temp;
- break;
- case 5: /*cloud*/
- plp=plt/3+32;
- if (plt++>25) pls=6;
- break;
- case 6: /*none*/
- break;
- }
- pldraw();
- ploccurestore(); /*restore occuvals*/
- }
- /**keydir**/
- /*returns a direction value upon return
- -1 indicates no direction*/
- short keydir()
- {
- int value;
- Point mypoint;
-
- value=-1;
- if(gkeyormouse)
- {
- mypoint.h=gTheEvent.where.h-16+mapx;
- mypoint.v=gTheEvent.where.v-16+mapy;
- GlobalToLocal(&mypoint);
- if(mypoint.h<plx+8 && mypoint.h>plx-8 &&
- mypoint.v<ply+8 && mypoint.v>ply-8) return(-1);
- if(mypoint.h<plx-1 && mypoint.v<ply+16 && mypoint.v>ply-16) return(1);
- if(mypoint.h>plx+1 && mypoint.v<ply+16 && mypoint.v>ply-16) return(0);
- if(mypoint.h<plx+16 && mypoint.h>plx-16 && mypoint.v>ply) return(3);
- if(mypoint.h<plx+16 && mypoint.h>plx-16 && mypoint.v<ply) return(2);
- if(mypoint.h<plx && mypoint.v>ply) value=6;
- if(mypoint.h>plx && mypoint.v>ply) value=7;
- if(mypoint.h>plx && mypoint.v<ply) value=4;
- if(mypoint.h<plx && mypoint.v<ply) value=5;
- }
- else
- {
- if (ispressed(88)||ispressed(0X02)||ispressed(0x7c)) value=0; /*right*/
- else if(ispressed2(86)||ispressed2(0x00)||ispressed(0x7b)) value=1; /*left*/
- else if(ispressed2(91)||ispressed2(0x0d)||ispressed(0x7e)) value=2; /*up*/
- else if(ispressed2(84)||ispressed2(0x07)||ispressed(0x7d)) value=3; /*down*/
- else if(ispressed2(92) || ispressed2(0x0e)) value=4; /*ur*/
- else if(ispressed2(89) || ispressed2(0x0c)) value=5; /*ul*/
- else if(ispressed2(83) || ispressed2(0x06)) value=6; /*dl*/
- else if(ispressed2(85) || ispressed2(0x08)) value=7; /*dr*/
- /*else value=-1;*/
- }
- return(value);
- }
-
- /**occuset**/
- /* in this order: mioccuset,ploccuset,ploccurestore*/
- mioccuset()
- {
- occuval[42]=0; /*opad*/
- }
- ploccuset()
- {
- occuval[24]=0; /*apple*/
- occuval[32]=0; /*superapple*/
- occuval[29]=0; /*treasure*/
- occuval[40]=1; /*xpad*/
- }
- ploccurestore() /*this is the default for all objects and monsters*/
- {
- occuval[24]=1; /*apple*/
- occuval[32]=1; /*superapple*/
- occuval[29]=1; /*treasure*/
- occuval[40]=0; /*xpad*/
- occuval[42]=1; /*opad*/
- }
-
- /***objects***/
- objects()
- {
- int loop;
-
- for(loop=0;loop<numobjects;loop++)
- {
- doobject(&object[loop]);
- }
- }
- /**doobject**/
- void doobject(struct objectdata *myobject)
- {
- switch((*myobject).status)
- {
- case 0:
- break;
- case APPLE:
- if (within(plx,ply,(*myobject).x,(*myobject).y,12,12))
- {
- objectdraw(25,(*myobject).x,(*myobject).y);
- thislevel[(*myobject).y/32][(*myobject).x/32]=0;
- (*myobject).status=0;
- healtht=healtht+32;
- if(healtht>MAXHEALTH) healtht=MAXHEALTH;
- sounder(gsndchannelc,yumhandle);
- }
- break;
- case SUPERAPPLE:
- if (within(plx,ply,(*myobject).x,(*myobject).y,12,12))
- {
- objectdraw(33,(*myobject).x,(*myobject).y);
- thislevel[(*myobject).y/32][(*myobject).x/32]=0;
- (*myobject).status=0;
- healtht=MAXHEALTH;
- /*if(healtht>MAXHEALTH) healtht=MAXHEALTH;*/
- sounder(gsndchannelc,yumhandle);
- }
- break;
- case KEY: /*key*/
- if (within(plx,ply,(*myobject).x,(*myobject).y,12,12))
- {
- objectdraw(0,(*myobject).x,(*myobject).y);
- thislevel[(*myobject).y/32][(*myobject).x/32]=0;
- (*myobject).status=0;
- gitemlist[gnumitems]=(*myobject).alt2;
- gnumitems++;
- displayitems();
- sounder(gsndchannelc,keyhandle);
- }
- break;
- case TREASURE: /*treasure*/
- if (within(plx,ply,(*myobject).x,(*myobject).y,16,16))
- {
- objectdraw((*myobject).pic,(*myobject).x,(*myobject).y);
- thislevel[(*myobject).y/32][(*myobject).x/32]=(*myobject).pic;
- (*myobject).status=0;
- if((*myobject).alt1) score+=(*myobject).alt1;
- else score+=5;
- displayscore();
- sounder(gsndchannelc,moneyhandle);
- }
- break;
- case KEYHOLE:
- if (within(plx,ply,(*myobject).x,(*myobject).y,16,16))
- {
- if (searchitems((*myobject).alt2)==-1) break;
- objectdraw(0,(*myobject).x,(*myobject).y);
- thislevel[(*myobject).y/32][(*myobject).x/32]=0;
- (*myobject).status=0;
- removeitem(searchitems((*myobject).alt2));
- gatestatus[(*myobject).alt1]=1;
- sounder(gsndchannelc,unlockhandle);
- }
- break;
- case GATE:
- gvara=(*myobject).alt1;
- if (gatestatus[gvara])
- {
- objectdraw(21,(*myobject).x,(*myobject).y);
- objectdraw(0,(*myobject).x+32,(*myobject).y);
- objectdraw(22,(*myobject).x+64,(*myobject).y);
- thislevel[(*myobject).y/32][(*myobject).x/32]=21;
- thislevel[(*myobject).y/32][(*myobject).x/32+1]=0;
- thislevel[(*myobject).y/32][(*myobject).x/32+2]=22;
- (*myobject).status=0;
- }
- break;
- case RING: /*ring*/
- if (within(plx,ply,(*myobject).x,(*myobject).y,12,12))
- {
- objectdraw(46,(*myobject).x,(*myobject).y);
- thislevel[(*myobject).y/32][(*myobject).x/32]=46;
- (*myobject).status=0;
- gitemlist[gnumitems]=RINGITEM;
- gnumitems++;
- displayitems();
- sounder(gsndchannelc,keyhandle);
- }
- break;
- }
- }
- /**within**/
- /*returns true if points are within tolerance of each other
- i.e. if any overlapping of "boxes" occurs. coordinates are
- upper left and boxes are square*/
- Boolean within(int x, int y, int x2, int y2,int size,int size2)
- {
- if (x<x2+size2 && x+size>x2 && y<y2+size2 && y+size>y2)
- return(TRUE);
- else
- return(FALSE);
- }
- /***objects2***/
- objects2()
- {
- int loop;
-
- for(loop=0;loop<numobjects;loop++)
- {
- doobject2(&object[loop]);
- }
- }
- /**doobject2**/
- /* for objects that must appear on top*/
- void doobject2(struct objectdata *myobject)
- {
- int addmybuggles,loop;
-
- switch((*myobject).status)
- {
- case 0:
- break;
- case MACHINE:
- if(gcounter&1)
- if(addmoremon&&((Random()&31)==0)) addmybuggles=1;
- else addmybuggles=0;
- if(nummonsters<3) addmybuggles=1;
- if(gcounter&1) (*myobject).transit++;
- if((*myobject).transit<(*myobject).alt1) addmybuggles=0;
- if(nummonsters+4>MAXMONSTERS) addmybuggles=0;
- for(loop=nummonsters;loop>=0;loop--)
- {
- if (monster[loop].status>=32 &&
- monster[loop].x>=(*myobject).x-64 &&
- monster[loop].x<=(*myobject).x &&
- monster[loop].y>=(*myobject).y-32 &&
- monster[loop].y<=(*myobject).y+32)
- {
- addmybuggles=0;
- overdraw(28,(*myobject).x,(*myobject).y);
- break;
- }
- }
- if (addmybuggles)
- {
- addmoremon=FALSE;
- (*myobject).transit=0;
- nummonsters++;
- monster[nummonsters].status=BUGGLES;
- monster[nummonsters].dir=1;
- monster[nummonsters].x=(*myobject).x;
- monster[nummonsters].y=(*myobject).y;
- monster[nummonsters].transit=0;
- monster[nummonsters].pic=4;
- monster[nummonsters].alt1=0;
- monster[nummonsters].alt2=24; /*temp ineffective*/
- }
- break;
- case INLETL:
- overdraw(30,(*myobject).x,(*myobject).y);
- break;
- case INLETR:
- overdraw(31,(*myobject).x,(*myobject).y);
- break;
- }
- }
-
- /***missiles***/
- missiles()
- {
- int loop;
-
- mioccuset();
- occumaster=0;
- for(loop=0;loop<MAXMISSILES;loop++)
- {
- domissile(&missile[loop]);
- }
- }
- /***domissile***/
- void domissile(struct missiledata *mymissile)
- {
- switch((*mymissile).status)
- {
- case 0: /*unused player missile*/
- if (ispressed(87) || ispressed(0x31) ||
- (Button()&&PtInRect(gTheEvent.where,&trueplayrect)))
- {
- if(masterstatus!=STATUS_OVER)(*mymissile).status=1;
- (*mymissile).dir=pld;
- (*mymissile).transit=0;
- (*mymissile).x=(plx+10)&32760; /*mask out 1,2 and 4*/
- (*mymissile).y=ply+8;
- (*mymissile).x+=dir12x[(*mymissile).dir];
- (*mymissile).y+=dir12y[(*mymissile).dir];
- (*mymissile).pic=missilepic[(*mymissile).dir];
- sounder(gsndchannelc,arrowhandle);
- }
- break;
- case 1: /*player missile in flight*/
- finals[numfinal].x=(*mymissile).x-mapx; /*erase old stuff*/
- finals[numfinal].y=(*mymissile).y-mapy;
- finals[numfinal].size=16;
- numfinal++;
- if((*mymissile).transit++>30)
- {
- (*mymissile).status=0;
- break;
- }
- (*mymissile).x+=dir12x[(*mymissile).dir];
- (*mymissile).y+=dir12y[(*mymissile).dir];
- if (occupied((*mymissile).x+8,(*mymissile).y+8))
- {
- (*mymissile).status=2;
- (*mymissile).transit=0;
- (*mymissile).dir=rebound[(*mymissile).dir];
- break;
- }
- minidraw((*mymissile).pic,(*mymissile).x,(*mymissile).y);
- break;
- case 2: /*missile explode*/
- (*mymissile).pic=arrowexplodepic[(*mymissile).transit];
- (*mymissile).x+=dir2x[(*mymissile).dir];
- (*mymissile).y+=dir2y[(*mymissile).dir];
- minidraw((*mymissile).pic,(*mymissile).x,(*mymissile).y);
- if((*mymissile).transit++>3) (*mymissile).status=0;
- break;
- case 3: /*unused missile*/
- break;
- case 4: /*firebolt*/
- finals[numfinal].x=(*mymissile).x-mapx; /*erase old stuff*/
- finals[numfinal].y=(*mymissile).y-mapy;
- finals[numfinal].size=4;
- numfinal++;
- if((*mymissile).transit++>70)
- {
- (*mymissile).status=3;
- break;
- }
- if(within(plx,ply,(*mymissile).x,(*mymissile).y,28,4))
- {
- healtht=healtht-10;
- (*mymissile).status=3;
- sounder(gsndchannelc,ouchhandle);
- break;
- }
- (*mymissile).x+=dir1x[(*mymissile).dir]*6;
- (*mymissile).y+=dir1y[(*mymissile).dir]*6;
- dotdraw((*mymissile).x,(*mymissile).y);
- break;
- }
- }
-
- /***monsters***/
- monsters()
- {
- for(gloop=nummonsters;gloop>=0;gloop--)
- {
- domonster(&monster[gloop]);
- }
- }
- /**domonster**/
- void domonster(struct monsterdata *mymonster)
- {
- int dir;
- switch((*mymonster).status)
- {
- case 0: /*null monster*/
- break;
- case BUGGLES:
- (*mymonster).transit++;
- if((*mymonster).transit>5) (*mymonster).transit=0;
- dir=getdir((*mymonster).x,(*mymonster).y);
- if((*mymonster).dir!=dir)
- {
- if((*mymonster).alt1++>23)
- {
- (*mymonster).alt1=0;
- (*mymonster).dir=dir;
- }
- }
- (*mymonster).pic=bugglewalkpic[(*mymonster).dir][(*mymonster).transit];
- occumaster=1;
- cango(&(*mymonster).x,&(*mymonster).y,
- dir2x[(*mymonster).dir],dir2y[(*mymonster).dir],(*mymonster).dir,31);
- mondraw((*mymonster).pic,(*mymonster).x,(*mymonster).y);
- if(missile[0].status==1)
- {
- if(within(missile[0].x+6,missile[0].y+6,(*mymonster).x,
- (*mymonster).y,4,32))
- {
- missile[0].status=2;
- missile[0].transit=0;
- (*mymonster).status=4;
- (*mymonster).transit=0;
- score+=1;
- displayscore();
- sounder(gsndchannelc,poofhandle);
- }
- }
- if ((*mymonster).alt2) (*mymonster).alt2--;
- else if(within(plx,ply,(*mymonster).x,(*mymonster).y,33,33))
- {
- sounder(gsndchannelc,ouchhandle);
- healtht=healtht-10;
- (*mymonster).alt2=16;
- }
- break;
- case BAT:
- (*mymonster).transit++;
- if((*mymonster).transit>15) (*mymonster).transit=0;
- dir=getdir((*mymonster).x,(*mymonster).y);
- if((*mymonster).dir!=dir)
- {
- if((*mymonster).pic++>8)
- {
- (*mymonster).pic=0; /*not actually used for pic*/
- (*mymonster).dir=dir;
- }
- }
- if(Randomize(50)<1) (*mymonster).dir=Randomize(9);
- (*mymonster).x+=dir1x[(*mymonster).dir];
- (*mymonster).y+=dir1y[(*mymonster).dir];
- minidraw(batpic[(*mymonster).transit],
- (*mymonster).x,(*mymonster).y);
- if(missile[0].status==1)
- {
- if(within(missile[0].x+8,missile[0].y+8,(*mymonster).x+2,
- (*mymonster).y,2,14))
- {
- missile[0].status=2;
- missile[0].transit=0;
- (*mymonster).status=3;
- (*mymonster).transit=0;
- /*score+=1;
- displayscore();*/
- sounder(gsndchannelc,bathandle);
- }
- }
- if(within(plx,ply,(*mymonster).x,(*mymonster).y,34,14))
- {
- sounder(gsndchannelc,ouchhandle);
- healtht=healtht-10;
- (*mymonster).status=3;
- (*mymonster).transit=7;
- }
-
- break;
- case 3: /*deadbat*/
- (*mymonster).y+=3;
- minidraw(deadbatpic[(*mymonster).transit],
- (*mymonster).x,(*mymonster).y);
- if(++(*mymonster).transit>=8)
- {
- (*mymonster).status=2;
- (*mymonster).x=(*mymonster).alt1;
- (*mymonster).y=(*mymonster).alt2;
- (*mymonster).transit=0;
- }
- break;
- case DEAD:
- (*mymonster).pic=scorerollpic[(*mymonster).transit];
- /*numfinal++;*/
- mondraw((*mymonster).pic,(*mymonster).x,(*mymonster).y);
- if(++(*mymonster).transit>23)
- {
- (*mymonster).status=0;
- (*mymonster).status=monster[nummonsters].status;
- (*mymonster).dir=monster[nummonsters].dir;
- (*mymonster).x=monster[nummonsters].x;
- (*mymonster).y=monster[nummonsters].y;
- (*mymonster).transit=monster[nummonsters].transit;
- (*mymonster).pic=monster[nummonsters].pic;
- (*mymonster).alt1=monster[nummonsters].alt1;
- (*mymonster).alt2=monster[nummonsters].alt2;
- nummonsters--;
- }
- break;
- case GHOST:
- (*mymonster).transit=(++(*mymonster).transit&63);
- dir=getdir2((*mymonster).x,(*mymonster).y);
- if(((*mymonster).dir!=dir)||((*mymonster).alt1>60))
- if(++(*mymonster).alt1>70)
- {
- (*mymonster).alt1=(gloop&15);
- (*mymonster).dir=dir;
- }
- if((*mymonster).alt1<=60)
- {
- (*mymonster).x+=dir2x[(*mymonster).dir];
- (*mymonster).y+=dir2y[(*mymonster).dir];
- }
- mondraw(ghostpic[(*mymonster).transit>>3],
- (*mymonster).x,(*mymonster).y);
- if ((*mymonster).alt2) (*mymonster).alt2--;
- else if(within(plx,ply,(*mymonster).x,(*mymonster).y,28,30))
- {
- sounder(gsndchannelc,ouchhandle);
- healtht=healtht-6;
- (*mymonster).alt2=16;
- }
- break;
- case POOLBALL:
- (*mymonster).transit++;
- if((*mymonster).transit>15) (*mymonster).transit=0;
- (*mymonster).pic=poolballpic[(*mymonster).dir][(*mymonster).transit];
- (*mymonster).x+=dir2x[(*mymonster).dir];
- mondraw((*mymonster).pic,(*mymonster).x,(*mymonster).y);
- if(missile[0].status==1)
- {
- if(within(missile[0].x+6,missile[0].y+6,(*mymonster).x,
- (*mymonster).y,4,32))
- {
- missile[0].status=2;
- missile[0].transit=0;
- }
- }
- if(within(plx,ply,(*mymonster).x,(*mymonster).y,16,16))
- {
- health=healtht=1;
- /*drawsidepanel();*/
- }
-
- if((*mymonster).x<-4) (*mymonster).x=736;
- break;
- case BEHOLD:
- (*mymonster).dir=getdir((*mymonster).x,(*mymonster).y);
- (*mymonster).x+=dir1x[(*mymonster).dir];
- (*mymonster).y+=dir1y[(*mymonster).dir];
- if((*mymonster).transit) (*mymonster).transit++;
- (*mymonster).transit=(*mymonster).transit&7;
- gvara=undu[((*mymonster).alt1++)>>2&3];
- mondraw(beholdpic[(*mymonster).transit],
- (*mymonster).x,(*mymonster).y+gvara);
- if(!(Random()&63))(*mymonster).transit=1; /*blink*/
-
- if((*mymonster).alt2<=0)
- for (gvara=1;gvara<MAXMISSILES;gvara++)
- {
- if(missile[gvara].status==3)
- {
- missile[gvara].status=4;
- missile[gvara].transit=0;
- missile[gvara].x=(*mymonster).x+16;
- missile[gvara].y=(*mymonster).y+16;
- missile[gvara].dir=(*mymonster).dir;
- (*mymonster).alt2=10;
- break;
- }
- }
- else (*mymonster).alt2--;
-
- if(missile[0].status==1)
- {
- if(within(missile[0].x+6,missile[0].y+6,(*mymonster).x,
- (*mymonster).y,4,32))
- {
- missile[0].status=2;
- missile[0].transit=0;
- missile[0].dir=rebound[missile[0].dir];
-
- (*mymonster).transit=0;
- if((*mymonster).pic++<3)
- (*mymonster).status=BEHOLDH;
- else
- {
- (*mymonster).status=DEAD;
- score+=1;
- displayscore();
- }
- }
- }
- break;
- case BEHOLDH:
- if(++(*mymonster).transit>127)
- (*mymonster).status=BEHOLD;
- gvara=undu[((*mymonster).alt1++)&3];
- if((*mymonster).transit>7) mondraw(53,(*mymonster).x,(*mymonster).y);
- else mondraw(50,(*mymonster).x,(*mymonster).y+gvara);
- if(missile[0].status==1)
- {
- if(within(missile[0].x+6,missile[0].y+6,(*mymonster).x,
- (*mymonster).y,4,32))
- {
- missile[0].status=2;
- missile[0].transit=0;
- missile[0].dir=rebound[missile[0].dir];
- }
- }
- break;
- case EGGLES:
- (*mymonster).transit++;
- if((*mymonster).transit==8 && (Random()&1)==0) (*mymonster).transit--;
- if((*mymonster).transit>7) (*mymonster).transit=0;
- dir=getdir((*mymonster).x,(*mymonster).y);
- if((*mymonster).dir!=dir)
- {
- if((*mymonster).alt1++>12)
- {
- (*mymonster).alt1=0;
- (*mymonster).dir=dir;
- }
- }
- (*mymonster).pic=egglewalkpic[(*mymonster).dir][(*mymonster).transit>>1];
- occumaster=3;
- if((*mymonster).transit<6)
- cango(&(*mymonster).x,&(*mymonster).y,
- dir1x[(*mymonster).dir],dir1y[(*mymonster).dir],(*mymonster).dir,15);
- if(missile[0].status==1)
- {
- if(within(missile[0].x+6,missile[0].y+6,(*mymonster).x,
- (*mymonster).y,4,16))
- {
- missile[0].status=2;
- missile[0].transit=0;
- (*mymonster).status=4;
- minidraw(47,(*mymonster).x,
- (*mymonster).y+bounce[(*mymonster).transit]);
- (*mymonster).transit=23;
- score+=1;
- sounder(gsndchannelc,eephandle);
- displayscore();
- return;
- }
- }
- minidraw((*mymonster).pic,(*mymonster).x,
- (*mymonster).y+bounce[(*mymonster).transit]);
- if ((*mymonster).alt2) (*mymonster).alt2--;
- else if(within(plx,ply,(*mymonster).x,(*mymonster).y,33,17))
- {
- sounder(gsndchannelc,ouchhandle);
- healtht=healtht-8;
- (*mymonster).alt2=16;
- }
- break;
- case ICECREAM:
- (*mymonster).transit=(++(*mymonster).transit)&31;
- (*mymonster).x+=dir1x[(*mymonster).dir];
- (*mymonster).x+=diricex[(*mymonster).transit>>2];
- (*mymonster).y+=dir1y[(*mymonster).dir];
- (*mymonster).y+=diricey[(*mymonster).transit>>2];
- mondraw(49,(*mymonster).x,(*mymonster).y);
- if(within(plx,ply,(*mymonster).x,(*mymonster).y,24,24))
- {
- sounder(gsndchannelc,yumhandle);
- healtht=MAXHEALTH;
- (*mymonster).status=DEAD;
- (*mymonster).transit=22;
- }
- if((*mymonster).x>(MAXLWIDTH*32+32)||(*mymonster).x<-32)
- {
- (*mymonster).status=DEAD;
- (*mymonster).transit=22;
- }
- break;
-
- }
- }
- /**getdir**/
- int getdir(int x,int y)
- {
- if(x<plx && y>ply) return(4);
- if(x>plx && y>ply) return(5);
- if(x>plx && y<ply) return(6);
- if(x<plx && y<ply) return(7);
- if (x<plx && y==ply) return(0);
- if (x>plx && y==ply) return(1);
- if (x==plx && y>ply) return(2);
- if (x==plx && y<ply) return(3);
- return(0);
- }
- /**getdir2**/
- /*a variation of the above with more vertical and horizontal*/
- int getdir2(int x,int y)
- {
- if (x<plx && y<ply+32 && y>ply-32) return(0);
- if (x>plx && y<ply+32 && y>ply-32) return(1);
- if (x<plx+32 && x>plx-32 && y>ply) return(2);
- if (x<plx+32 && x>plx-32 && y<ply) return(3);
- if(x<plx && y>ply) return(4);
- if(x>plx && y>ply) return(5);
- if(x>plx && y<ply) return(6);
- if(x<plx && y<ply) return(7);
- return(0);
- }
-
- /**ispressed**/
- /*this functions returns a boolean TRUE if keyboard scan code is pressed*/
- Boolean ispressed(unsigned short k)
- {
- /* unsigned char km[16];*/
-
- GetKeys((long *)gkm);
- return((gkm[k>>3]>>(k&7))&1);
- }
- /**ispressed2**/
- /*similar to version 1 but does not call get keys*/
- Boolean ispressed2(unsigned short k)
- {
- return((gkm[k>>3]>>(k&7))&1);
- }
-
-
- /***can go***/
- /*this routine takes x,y,xmod,ymod,direction, size and
- returns legal x and y after modification*/
- void cango(int *x,int *y,int xmod,int ymod,int direction,int size)
- {
- int temp;
-
- if (occuval[thislevel[*y>>5][*x>>5]]||
- occuval[thislevel[*y>>5][(*x+size)>>5]]||
- occuval[thislevel[(*y+size)>>5][*x>>5]]||
- occuval[thislevel[(*y+size)>>5][(*x+size)>>5]])
- {
- *x=*x+xmod;
- *y=*y+ymod;
- direction=8; /*if already encased let us out*/
- }
- switch(direction)
- {
- case 0:
- if (!occupied(*x+xmod+size,*y) && !occupied(*x+xmod+size,*y+size))
- {
- *x=*x+xmod;
- break;
- }
- if (!occupied(*x+xmod+size,*y) && occupied(*x+xmod+size,*y+size))
- {
- if (!occupied(*x,*y-2) && !occupied(*x+size,*y-2))
- {
- *y=*y-2;
- break;
- }
- }
- if (occupied(*x+xmod+size,*y) && !occupied(*x+xmod+size,*y+size))
- {
- if (!occupied(*x,*y+2+size) && !occupied(*x+size,*y+2+size))
- {
- *y=*y+2;
- break;
- }
- }
- break;
- case 1:
- if (!occupied(*x+xmod,*y) && !occupied(*x+xmod,*y+size))
- {
- *x=*x+xmod;
- break;
- }
- if (!occupied(*x+xmod,*y) && occupied(*x+xmod,*y+size))
- {
- if (!occupied(*x,*y-2) && !occupied(*x+size,*y-2))
- {
- *y=*y-2;
- break;
- }
- }
- if (occupied(*x+xmod,*y) && !occupied(*x+xmod,*y+size))
- {
- if (!occupied(*x,*y+2+size) && !occupied(*x+size,*y+2+size))
- {
- *y=*y+2;
- break;
- }
- }
- break;
- case 2:
- if (!occupied(*x,*y+ymod) && !occupied(*x+size,*y+ymod))
- {
- *y=*y+ymod;
- break;
- }
- if (!occupied(*x,*y+ymod) && occupied(*x+size,*y+ymod))
- {
- if (!occupied(*x-2,*y) && !occupied(*x-2,*y+size))
- {
- *x=*x-2;
- break;
- }
- }
- if (occupied(*x,*y+ymod) && !occupied(*x+size,*y+ymod))
- {
- if (!occupied(*x+2+size,*y) && !occupied(*x+2+size,*y+size))
- {
- *x=*x+2;
- break;
- }
- }
- break;
- case 3:
- if (!occupied(*x,*y+ymod+size) && !occupied(*x+size,*y+ymod+size))
- {
- *y=*y+ymod;
- break;
- }
- if (!occupied(*x,*y+ymod+size) && occupied(*x+size,*y+ymod+size))
- {
- if (!occupied(*x-2,*y) && !occupied(*x-2,*y+size))
- {
- *x=*x-2;
- break;
- }
- }
- if (occupied(*x,*y+ymod+size) && !occupied(*x+size,*y+ymod+size))
- {
- if (!occupied(*x+2+size,*y) && !occupied(*x+2+size,*y+size))
- {
- *x=*x+2;
- break;
- }
- }
- break;
- case 4:
- case 5:
- case 6:
- case 7:
- if (!occupied(*x+xmod+size,*y+ymod) &&
- !occupied(*x+xmod,*y+ymod) &&
- !occupied(*x+xmod+size,*y+ymod+size) &&
- !occupied(*x+xmod,*y+ymod+size))
- {
- *x+=xmod;
- *y+=ymod;
- break;
- }
- else if (occupied(*x+xmod+size,*y)==0 &&
- occupied(*x+xmod+size,*y+size)==0 &&
- occupied(*x+xmod,*y)==0 &&
- occupied(*x+xmod,*y+size)==0)
- {
- *x=*x+xmod;
- break;
- }
- else if (occupied(*x,*y+ymod)==0 &&
- occupied(*x+size,*y+ymod)==0 &&
- occupied(*x,*y+ymod+size)==0 &&
- occupied(*x+size,*y+ymod+size)==0)
- {
- *y=*y+ymod;
- break;
- }
- occumaster=0;
- }
- }
- /***can go2***/
- /*this routine takes x,y,xmod,ymod,direction, size and
- returns legal x and y after modification
- it is similar to can go but has less smoothing
- for things moving cardinally*/
- void cango2(int *x,int *y,int xmod,int ymod,int direction,int size)
- {
- int temp;
-
- if (occuval[thislevel[*y>>5][*x>>5]]||
- occuval[thislevel[*y>>5][(*x+size)>>5]]||
- occuval[thislevel[(*y+size)>>5][*x>>5]]||
- occuval[thislevel[(*y+size)>>5][(*x+size)>>5]])
- {
- *x=*x+xmod;
- *y=*y+ymod;
- direction=8; /*if already encased let us out*/
- }
- switch(direction)
- {
- case 0:
- if (!occupied(*x+xmod+size,*y) && !occupied(*x+xmod+size,*y+size))
- {
- *x=*x+xmod;
- break;
- }
- if (!occupied(*x+xmod+size,*y+size-9) && occupied(*x+xmod+size,*y+size))
- {
- if (!occupied(*x,*y-2) && !occupied(*x+size,*y-2))
- {
- *y=*y-2;
- break;
- }
- }
- if (occupied(*x+xmod+size,*y) && !occupied(*x+xmod+size,*y+9))
- {
- if (!occupied(*x,*y+2+size) && !occupied(*x+size,*y+2+size))
- {
- *y=*y+2;
- break;
- }
- }
- break;
- case 1:
- if (!occupied(*x+xmod,*y) && !occupied(*x+xmod,*y+size))
- {
- *x=*x+xmod;
- break;
- }
- if (!occupied(*x+xmod,*y+size-9) && occupied(*x+xmod,*y+size))
- {
- if (!occupied(*x,*y-2) && !occupied(*x+size,*y-2))
- {
- *y=*y-2;
- break;
- }
- }
- if (occupied(*x+xmod,*y) && !occupied(*x+xmod,*y+9))
- {
- if (!occupied(*x,*y+2+size) && !occupied(*x+size,*y+2+size))
- {
- *y=*y+2;
- break;
- }
- }
- break;
- case 2:
- if (!occupied(*x,*y+ymod) && !occupied(*x+size,*y+ymod))
- {
- *y=*y+ymod;
- break;
- }
- if (!occupied(*x+size-9,*y+ymod) && occupied(*x+size,*y+ymod))
- {
- if (!occupied(*x-2,*y) && !occupied(*x-2,*y+size))
- {
- *x=*x-2;
- break;
- }
- }
- if (occupied(*x,*y+ymod) && !occupied(*x+9,*y+ymod))
- {
- if (!occupied(*x+2+size,*y) && !occupied(*x+2+size,*y+size))
- {
- *x=*x+2;
- break;
- }
- }
- break;
- case 3:
- if (!occupied(*x,*y+ymod+size) && !occupied(*x+size,*y+ymod+size))
- {
- *y=*y+ymod;
- break;
- }
- if (!occupied(*x+size-9,*y+ymod+size) && occupied(*x+size,*y+ymod+size))
- {
- if (!occupied(*x-2,*y) && !occupied(*x-2,*y+size))
- {
- *x=*x-2;
- break;
- }
- }
- if (occupied(*x,*y+ymod+size) && !occupied(*x+9,*y+ymod+size))
- {
- if (!occupied(*x+2+size,*y) && !occupied(*x+2+size,*y+size))
- {
- *x=*x+2;
- break;
- }
- }
- break;
- case 4:
- case 5:
- case 6:
- case 7:
- if (!occupied(*x+xmod+size,*y+ymod) &&
- !occupied(*x+xmod,*y+ymod) &&
- !occupied(*x+xmod+size,*y+ymod+size) &&
- !occupied(*x+xmod,*y+ymod+size))
- {
- *x+=xmod;
- *y+=ymod;
- break;
- }
- else if (occupied(*x+xmod+size,*y)==0 &&
- occupied(*x+xmod+size,*y+size)==0 &&
- occupied(*x+xmod,*y)==0 &&
- occupied(*x+xmod,*y+size)==0)
- {
- *x=*x+xmod;
- break;
- }
- else if (occupied(*x,*y+ymod)==0 &&
- occupied(*x+size,*y+ymod)==0 &&
- occupied(*x,*y+ymod+size)==0 &&
- occupied(*x+size,*y+ymod+size)==0)
- {
- *y=*y+ymod;
- break;
- }
- occumaster=0;
- }
- }
- /**occupied**/
- /*this function takes absolute coordinates and returns
- a nonzero if occupied, 0 if the space is empty*/
- Boolean occupied(int x,int y)
- {
- register int value,loop;
- switch(occumaster)
- {
- case 0: /*sense only landscape*/
- return(occuval[thislevel[y>>5][x>>5]]);
- break;
- case 1: /*sense player and sense monsters except number gloop*/
- value=occuval[thislevel[y>>5][x>>5]];
- if(value==0)
- {
- for(loop=nummonsters;loop>=0;loop--)
- {
- if (monster[loop].status>=32 && loop!=gloop)
- {
- if (x>monster[loop].x && x<monster[loop].x+32 &&
- y>monster[loop].y && y<monster[loop].y+32)
- value=1;
- }
- }
- if (x>plx && x<plx+32 && y>ply && y<ply+32
- && masterstatus==STATUS_GAME) value=1;
- }
- return(value);
- break;
- case 2: /*sense monsters*/
- value=occuval[thislevel[y>>5][x>>5]];
- if(value==0)
- {
- for(loop=nummonsters;loop>=0;loop--)
- {
- if (monster[loop].status>=32)
- {
- if (x>monster[loop].x && x<monster[loop].x+32 &&
- y>monster[loop].y && y<monster[loop].y+32)
- value=1;
- }
- }
- }
- return(value);
- break;
- case 3: /*sense eggles*/
- value=occuval[thislevel[y>>5][x>>5]];
- if(value==0)
- {
- for(loop=nummonsters;loop>=0;loop--)
- {
- if (monster[loop].status==EGGLES && loop!=gloop)
- {
- if (x>monster[loop].x && x<monster[loop].x+16 &&
- y>monster[loop].y && y<monster[loop].y+16)
- value=1;
- }
- }
- }
- return(value);
- break;
- }
- }
-
-
-
- /*** helpdialog ***/
- helpdialog(void)
- {
- Boolean dialogDone=FALSE;
- short itemHit;
- short itemType;
- Rect itemRect;
- Handle itemHandle;
- DialogPtr helpdiaptr;
- short loop,x,y;
- Point p;
- PicHandle temppict;
- UniversalProcPtr mypicproc;
- UniversalProcPtr mydiafilter;
-
- InitCursor();
- helpdiaptr=GetNewDialog(402,NIL_POINTER,(WindowPtr)MOVE_TO_FRONT);
- gcard=0;
- /*p.h=370; p.v=20;
- LocalToGlobal(&p);
- MoveWindow(helpdiaptr,p.h,p.v,FALSE);*/
-
-
- mypicproc=NewRoutineDescriptor((ProcPtr)pictproc,uppUserItemProcInfo,GetCurrentISA());
- GetDItem(helpdiaptr,4,&itemType,&itemHandle,&itemRect);
- SetDItem(helpdiaptr,4,itemType,(Handle)mypicproc,&itemRect);
-
- DrawDialog(helpdiaptr);
- ShowWindow(helpdiaptr);
- SetPort(helpdiaptr);
-
- while(dialogDone==FALSE)
- {
- mydiafilter=NewRoutineDescriptor((ProcPtr)helpfilter,uppModalFilterProcInfo,GetCurrentISA());
- ModalDialog((ModalFilterUPP)mydiafilter,&itemHit);
- switch(itemHit)
- {
- case 1: /*ok*/
- HideWindow(helpdiaptr);
- dialogDone=TRUE;
- break;
- case 2: /*left*/
- if(--gcard<0) gcard=2;
- DrawDialog(helpdiaptr);
- break;
- case 3: /*right*/
- if(++gcard>4) gcard=0;
- DrawDialog(helpdiaptr);
- break;
- case 4: /*center*/
- if(gcard==0)
- {
- HideWindow(helpdiaptr);
- dialogDone=TRUE;
- }
- else
- { /*send to first card*/
- gcard=0;
- DrawDialog(helpdiaptr);
- }
- break;
- default:
- break;
- }
- }
- DisposDialog(helpdiaptr);
- SetPort(myWindow);
- }
- /**helpfilter**/
- pascal Boolean helpfilter(DialogPtr theDlg,EventRecord *theEvent,
- short *itemHit )
- {
- short loop;
- short x,y;
- Point p;
- Rect myrect;
-
- p=theEvent->where;
- GlobalToLocal(&p);
- if(theEvent->what==mouseDown)
- {
- SetRect(&myrect,352,224,382,254);
- if(PtInRect(p,&myrect))
- {
- InvertRect(&myrect);
- while (Button())
- {
- }
- InvertRect(&myrect);
- *itemHit=3;
- return(TRUE);
- }
- SetRect(&myrect,2,224,32,254);
- if(PtInRect(p,&myrect))
- {
- InvertRect(&myrect);
- while (Button())
- {
- }
- InvertRect(&myrect);
- *itemHit=2;
- return(TRUE);
- }
- SetRect(&myrect,34,224,350,254);
- if(PtInRect(p,&myrect))
- {
- InvertRect(&myrect);
- while (Button())
- {
- }
- InvertRect(&myrect);
- *itemHit=4;
- return(TRUE);
- }
-
- *itemHit = ok;
- return( TRUE ); // Note: pascal-style TRUE
- }
-
- if ( theEvent->what != keyDown ) // just looking for keystrokes
- return(FALSE);
-
- switch ( (theEvent->message) & charCodeMask ) {
- case 0x0d: // Return pressed or ...
- case 0x03: // ... Enter pressed
- case 0x1b: // Esc pressed
- *itemHit = ok;
- return( TRUE ); // Note: pascal-style TRUE
- default:
- return( FALSE ); // all others
- }
- }
-
- //*proc to draw pict*/
- pascal void pictproc(WindowPtr theDlg,short theItem )
- {
- Rect iRect;
- Handle iHndl;
- short iType;
-
- /*GetDItem (theDlg, 1, &iType, &iHndl, &iRect );*/
- LDR(gbasepic+51+gcard,0,0);
- }
-
- /*** quitdialog ***/
- quitdialog(void)
- {
- Boolean dialogDone=FALSE;
- short itemHit;
- short itemType;
- Rect itemRect;
- Handle itemHandle;
- DialogPtr quitdiaptr;
- short loop,x,y;
- Point p;
- UniversalProcPtr mydiafilter;
- UniversalProcPtr myokproc;
-
- InitCursor();
- quitdiaptr=GetNewDialog(403,NIL_POINTER,(WindowPtr)MOVE_TO_FRONT);
- myokproc=NewRoutineDescriptor((ProcPtr)okitemproc,uppUserItemProcInfo,GetCurrentISA());
- GetDItem(quitdiaptr,4,&itemType,&itemHandle,&itemRect);
- SetDItem(quitdiaptr,4,itemType,(Handle)myokproc,&itemRect);
-
- DrawDialog(quitdiaptr);
- ShowWindow(quitdiaptr);
- SetPort(quitdiaptr);
-
- while(dialogDone==FALSE)
- {
- mydiafilter=NewRoutineDescriptor((ProcPtr)diafilter,uppModalFilterProcInfo,GetCurrentISA());
- ModalDialog((ModalFilterUPP)mydiafilter,&itemHit);
- switch(itemHit)
- {
- case 1: /*ok*/
- HideWindow(quitdiaptr);
- dialogDone=TRUE;
- masterstatus=STATUS_QUIT;
- break;
- case 2: /*cancel*/
- HideWindow(quitdiaptr);
- dialogDone=TRUE;
- break;
- default:
- break;
- }
- }
- DisposDialog(quitdiaptr);
- SetPort(myWindow);
- }
-